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

最佳答案

你错了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)=>

关于netezza - Netezza:如何在表中添加列,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/10791332/

10-12 17:34