How to drop multiple columns in PostgreSQL Ask Question

How to drop multiple columns in PostgreSQL Ask Question

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"

ベストアンサー1

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.)

おすすめ記事