View Single Post
  #2 (permalink)  
Old 10-28-04, 23:06
zalew zalew is offline
Registered User
 
Join Date: Oct 2004
Posts: 3
hi. in postgres you can't so easily change column type.. the documentation of 'alter table' there's no word about changing column type, as if they didn't want to talk about it
for a long time i thought it was only possible by recreating the table, but i found something like this in the faq
Quote:
To change the data type of a column, do this:

BEGIN;
ALTER TABLE tab ADD COLUMN new_col new_data_type;
UPDATE tab SET new_col = CAST(old_col AS new_data_type);
ALTER TABLE tab DROP COLUMN old_col;
COMMIT;

You might then want to do VACUUM FULL tab to reclaim the disk space used by the expired rows.
Reply With Quote