How to drop multiple columns in postgresql
PostgresqlPostgresql Problem Overview
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"
Postgresql Solutions
Solution 1 - Postgresql
Check this:
ALTER TABLE table DROP COLUMN col1, DROP COLUMN col2;
Solution 2 - Postgresql
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;
Solution 3 - Postgresql
This worked for me:
alter table your_table_name drop column your_column_name;