Reputation: 197
I am new to netezza. I need to know how can we rename two columns with a single query.
I've tried ,
ALTER TABLE tabemp RENAME COLUMN salary to empsalary and name to empname;
ALTER TABLE tabemp RENAME COLUMN salary to empsalary , name to empname;
But none of these is working.
Thanks.
Upvotes: 2
Views: 7017
Reputation: 36
With a query, only one column can be renamed at a time. You can write a wrapper script to rename multiple columns or use IBM Netezza Performance portal to edit the table. Check the link here!
Upvotes: 2
Reputation: 3887
You can only rename one column at a time with ALTER TABLE.
From the documentation, which can be found at this link, you can see that ADD COLUMN is the only action which allows multiple specifications:
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>
Upvotes: 1