Netezza:如何向表中添加列

时间:2012-05-28 23:05:49

标签: netezza

ALTER TABLE table_name不支持ADD列。有没有其他方法可以向表中添加列?

1 个答案:

答案 0 :(得分:8)

你错了。 Netezza支持添加列。 “数据库用户指南”中对此进行了描述,B-19部分介绍了ALTER TABLE语法。

请参阅nzsql的输出:

LABDB(ADMIN)=> CREATE TABLE REGION2 AS SELECT * FROM REGION;
INSERT 0 4
Elapsed time: 0m0.138s
LABDB(ADMIN)=> ALTER TABLE REGION2 ADD r_col1 char(8);
ALTER TABLE
Elapsed time: 0m0.145s
LABDB(ADMIN)=> SELECT * FROM REGION2;
 R_REGIONKEY |          R_NAME           |          R_COMMENT          | R_COL1
-------------+---------------------------+-----------------------------+--------
           4 | ap                        | asia pacific                |
           3 | emea                      | europe, middle east, africa |
           2 | sa                        | south america               |
           1 | na                        | north america               |
(4 rows)

Elapsed time: 0m0.510s
LABDB(ADMIN)=> UPDATE REGION2 SET r_col1 = 'AABBAABB';
UPDATE 4
Elapsed time: 0m1.256s
LABDB(ADMIN)=> SELECT * FROM REGION2;
 R_REGIONKEY |          R_NAME           |          R_COMMENT          |  R_COL1
-------------+---------------------------+-----------------------------+----------
           1 | na                        | north america               | AABBAABB
           3 | emea                      | europe, middle east, africa | AABBAABB
           4 | ap                        | asia pacific                | AABBAABB
           2 | sa                        | south america               | AABBAABB
(4 rows)

Elapsed time: 0m0.111s
LABDB(ADMIN)=>