PostgreSQL Alter table drop multiple columns from table

To drop multiple columns from a PostgreSQL table using the ALTER TABLE statement, you can follow these steps:

Connect to your PostgreSQL database using a client or command-line interface.


Execute the following ALTER TABLE statement:

ALTER TABLE table_name
DROP COLUMN column_name1,
DROP COLUMN column_name2,
DROP COLUMN column_nameN;

Replace table_name with the name of the table from which you want to drop the columns. Replace column_name1, column_name2, etc., with the names of the columns you want to remove.


For example, let’s say you have a table called employees with columns employee_id, first_name, last_name, email, and phone_number. To drop the columns email and phone_number, the ALTER TABLE statement would look like this:

ALTER TABLE employees
DROP COLUMN phone_number;

Execute the ALTER TABLE statement to drop the specified columns from the table.
Please note that dropping columns from a table can result in the loss of data. Make sure to backup your data and review the consequences before performing this operation.