How to drop multiple columns in PostgreSQL

In this article, we will see how to drop multiple columns in PostgreSQL with examples. We can drop columns by using alter table command.

Syntax to drop multiple columns in PostgreSQL

ALTER TABLE DROP COLUMN column1, DROP COLUMN column2;

We have to mention drop command before every column in the ALTER TABLE command.

Examples:

Table "public.salesreport" Column | Type | Collation | Nullable | Default | Storage | Stats target | Description -----------+-----------------------+-----------+----------+---------+----------+--------------+------------- id | integer | | | | plain | | s_name | character varying(30) | | | | extended | | s_loc | character varying(20) | | | | extended | | s_state | character varying(10) | | | | extended | | s_city | character varying(30) | | | | extended | | s_zipcode | character varying(10) | | | | extended |

1. From the above table drop columns s_state and s_loc columns.

ALTER TABLE salesreport DROP COLUMN s_state, DROP COLUMN s_loc;

How to drop multiple columns in PostgreSQL

2. Now, verify columns have been removed successfully or not.

\d+ salesreport

So in this article, we have seen how to drop multiple columns in PostgreSQL.