knel knel - 6 months ago 9
SQL Question

Alter table to change column data type

I run

ALTER TABLE tbl_name ALTER COLUMN col_name varchar (11);


I am using PostgreSQL. what am I doing wrong?

Answer

See documentation here: http://www.postgresql.org/docs/current/interactive/sql-altertable.html

ALTER TABLE tbl_name ALTER COLUMN col_name TYPE varchar (11);

Edit

According to the link and 2nd comment today's syntax should be (as in the question):

ALTER TABLE tbl_name ALTER [COLUMN] col_name varchar(11);

Maybe older PostgreSQL versions were different.