I have a question about the ALTER TABLE
command on a really large table (almost 30 millions rows).
One of its columns is a varchar(255)
and I would like to resize it to a varchar(40)
.
Basically, I would like to change my column by running the following command:
ALTER TABLE mytable ALTER COLUMN mycolumn TYPE varchar(40);
I have no problem if the process is very long but it seems my table is no more readable during the ALTER TABLE
command.
Is there a smarter way? Maybe add a new column, copy values from the old column, drop the old column and finally rename the new one?
Note: I use PostgreSQL 9.0.