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

标签 database amazon-redshift ddl

你好,我正在尝试从我的表中删除列,特别是在 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/

相关文章:

mysql - 基于主表更新从属表

java - 安全配置 http 数据库类型=Forbidden,状态=403

sql-server - SQL Server 2008R2 : 'DELETE FROM' hangs forever, 但 'SELECT' 工作正常

sql - aws redshift 中的 ILIKE 和 NOT ILIKE 与 total 不同

amazon-s3 - 如何从 Redshift 表中仅卸载 1000 行

sql - 事务回滚时更新统计信息的行为

sql - 在不丢失数据的情况下将列类型字符 varying(3) 更改为 bool 值

php - MySQL SELECT where if 条件组

amazon-web-services - 如何将存储桶所有者完全控制权授予从一个帐户中的 redshift 卸载到另一个帐户中的 s3 存储桶的文件?

mysql - 多次遇到mysql中小数这个难点