Alter table drop multiple columns from table

PostreSQL tutorial – Drop multiple columns

Drop multiple columns from table

How to drop multiple columns from existing table. Alter syntax and example.

Syntax

ALTER TABLE table_name 
DROP COLUMN column_name,
DROP COLUMN column_name RESTRICT;

Create table

CREATE TABLE users(
userid numeric not null 
default nextval('seq_users'::regclass),
username varchar(100),
userpass varchar(250),
usermail varchar(50),
address varchar(1000),
first_name varchar(100)
last_name varchar(100)  
);    

Example Drop multiple columns

ALTER TABLE users 
DROP COLUMN first_name,  
DROP COLUMN last_name RESTRICT; 

Alter table |
Drop table