2

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

4

1 回答 1

9

你大错特错。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)=>
于 2012-05-30T13:59:10.877 回答