PostgreSQL – Add columns to an existing table

Below is the syntax to add a new column to an existing table in Postgres database.

ALTER TABLE table_name ADD COLUMN column_name datatype;

Example:

ALTER TABLE person ADD COLUMN email varchar(100);

Syntax to add multiple columns to a table:

ALTER TABLE table_name 
ADD COLUMN column_name1 datatype1,
ADD COLUMN column_name2 datatype2,
ADD COLUMN column_name3 datatype3;

Example:

ALTER TABLE employee 
ADD COLUMN salary integer,
ADD COLUMN email varchar2(100),
ADD COLUMN title varchar2(100);
See also  PostgreSQL - Remove all special characters from a string