使用单个查询重命名 netezza 中的两列

Rename two columns in netezza using single query

我是 netezza 新手。我需要知道如何使用单个查询重命名两列。

我试过了,

ALTER TABLE tabemp RENAME COLUMN salary to empsalary and name to empname;

ALTER TABLE tabemp RENAME COLUMN salary to empsalary , name to empname;

但是其中 none 个有效。

谢谢。

您一次只能使用 ALTER 重命名一列 TABLE。

From the documentation, which can be found at this link, 您可以看到 ADD COLUMN 是唯一允许多个规范的操作:

ALTER TABLE <table> <action> [ORGANIZE ON {(<columns>) | NONE}]

Where <action> can be one of:

ADD COLUMN <col> <type> [<col_constraint>][,…] |  

ADD <table_constraint> |  

ALTER [COLUMN] <col> { SET DEFAULT <value> |  DROP DEFAULT } |  

DROP [COLUMN] column_name[,column_name…] {CASCADE | RESTRICT } |  

DROP CONSTRAINT <constraint_name> {CASCADE | RESTRICT} | 

MODIFY COLUMN (<col> VARCHAR(<maxsize>)) |  

OWNER TO <user_name> | 

RENAME [COLUMN] <col> TO <new_col_name> | 

RENAME TO <new_table> |  

SET PRIVILEGES TO <table>

对于查询,一次只能重命名一列。您可以编写包装器脚本来重命名多个列或使用 IBM Netezza Performance 门户来编辑 table。检查 link here!