PostgreSQL – Change Column datatype

Below is the syntax to change the data type of a column. tablename is the name of the table, columnname is the name of the column and newdatatype is the new data type for the column.

ALTER TABLE tablename ALTER COLUMN columnname TYPE newdatatype;

You can change the data types of multiple columns of a table at once using the below syntax:

ALTER TABLE tablename 
ALTER COLUMN columnname1 TYPE newdatatype1,
ALTER COLUMN columnname2 TYPE newdatatype2;

See also  PostgreSQL - MAX Function