gpt4 book ai didi

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

转载 作者:搜寻专家 更新时间:2023-10-30 21:56:07 25 4
gpt4 key购买 nike

你好,我正在尝试从我的表中删除列,特别是在 Amazon Redshift 数据库中,我已经尝试过“Alter Table ABC drop column C1,drop column C2”和“Alter Table ABC drop column C1,C2)”但它显示错误并且没有执行

最佳答案

来自 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;

关于database - 我应该如何在 redshift 数据库中删除多个列?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48341425/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com