在 T
eradata 数据库环境中,如何修改一个已经存在记录的表字段类型呢?
因为不能通过 alter 方式直接修改字段类型。要么先 alter drop 字段,再 alter add 字段。但是这样会丢失字段的数据。
我们可以先通过 create tableA as (select ... from tableB) with data; 再 drop table tableB 方式“曲线救国”。
给定一个例子:
- create table access_log_1(CLIENT_IP,cost_time) as
(select IP,cost_time (decimal(10,2)) from access_log) with data; - drop table access_log;
- rename table acccess_log_1 to access_log;