Reputation: 5667
I want to drop 200 columns in my table in PostgreSQL. I tried:
ALTER TABLE my_table
DROP COLUMN col1, col2
But I get an error like this:
ERROR: syntax error at or near "col2"
Upvotes: 167
Views: 93649
Reputation: 4318
As per the docs, you can do this:
ALTER TABLE table DROP COLUMN col1, DROP COLUMN col2;
(You may need to wrap some of your column names in "
quotes if they happen to be keywords.)
Upvotes: 317
Reputation: 1627
Thanks long & Ondrej - below commands worked for me,
ALTER TABLE table_name DROP COLUMN column_name_1,DROP COLUMN column_name_2,DROP COLUMN column_name_3;
ALTER TABLE table_name DROP column_name_1,DROP column_name_2,DROP column_name_3;
Upvotes: -1
Reputation: 983
This worked for me:
alter table your_table_name drop column your_column_name;
Upvotes: -5