2012/09/05

Alter column length in Teradata

in teradata ,DDL alter table can not only add column but also can alter column length in specific case

eg.

DDL:

create table bbb
(col1 varchar(10),
col2 varchar(20)
)

DML:
alter  table bbb  ADD col2  varchar(100)

RESULT:
ALTER TABLE completed. Elapsed Time = 00:00:00

but, in the case , if the column is defined char but not varchar

DDL:

create table aaa
(col1 char(10),
col2 char(20)
)


DML:
ALTER table aaa  ADD col2  VARCHAR(15)

RESULT:
ALTER TABLE Failed.  [3558] Cannot alter the specified attribute(s) for COL2.

as we see, modify column length by "alter table ", the conditions are strictly limited.

so, usually, we create a new table with the new defined column length ,then do a ins-sel and finally rename the table.

No comments:

Post a Comment