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"
Syntax. The syntax to drop a column in a table in PostgreSQL (using the ALTER TABLE statement) is: ALTER TABLE table_name DROP COLUMN column_name; table_name.
If you specify a list of columns, you need to place a comma ( , ) between two columns to separate them. If you want to select data from all the columns of the table, you can use an asterisk ( * ) shorthand instead of specifying all the column names.
Check this:
ALTER TABLE table DROP COLUMN col1, DROP COLUMN col2;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With