排除Redshift Spectrum SQL查询中的列

时间:2019-10-03 19:33:43

标签: sql amazon-s3 amazon-redshift amazon-redshift-spectrum

在我的表中有col1,col2 ..... coln列

我想

select all columns except col1

我可以指定

而不是选择select col2,col3 .... coln
select * from <table name> except col1

选择除一列外的所有列

1 个答案:

答案 0 :(得分:0)

您可以执行以下操作-

-- create a temporary copy of your table
SELECT * INTO temp_table FROM original_table;

-- drop the column you don't need
ALTER TABLE temp_table DROP COLUMN col1;

-- select all columns
SELECT * FROM temp_table;

-- drop the temporary table
DROP TABLE temp_table;