我应该如何删除redshift数据库中的多个列?

时间:2018-01-19 12:43:25

标签: database amazon-redshift

您好我正在尝试从 Amazon Redshift数据库中删除我的表中的列我尝试过“更改表ABC删除列C1,删除列C2 ”和“ 更改表ABC删除列C1,C2)“但它显示错误但未执行

1 个答案:

答案 0 :(得分:3)

Redshift's ALTER TABLE documentation开始,不能一次删除几列,cf:

ALTER TABLE table_name
{
ADD table_constraint |
DROP CONSTRAINT constraint_name [ RESTRICT | CASCADE ] |
OWNER TO new_owner |
RENAME TO new_name |
RENAME COLUMN column_name TO new_name |
ADD [ COLUMN ] column_name column_type
[ DEFAULT default_expr ]
[ ENCODE encoding ]
[ NOT NULL | NULL ] |
DROP [ COLUMN ] column_name [ RESTRICT | CASCADE ] }

where table_constraint is:

[ CONSTRAINT constraint_name ]
{ UNIQUE ( column_name [, ... ] )  |
PRIMARY KEY ( column_name [, ... ] ) |
FOREIGN KEY (column_name [, ... ] )
REFERENCES  reftable [ ( refcolumn ) ]}

因此,我建议您按以下步骤操作:

ALTER TABLE ABC DROP COLUMN C1;
ALTER TABLE ABC DROP COLUMN C2;