Thread: Fw: Change column data type
Dear Friends,
Using Postgres 7.3.4 over the linux server 7.3.
Is it possible to alter/change the data type of a existing table's column, with out dropping and recreating a column of same name.
Thanks for ur knowledge sharing.
Regards
Kumar
On Tue, 2 Sep 2003, Kumar wrote: > > Dear Friends, > > Using Postgres 7.3.4 over the linux server 7.3. > > Is it possible to alter/change the data type of a existing table's > column, with out dropping and recreating a column of same name. Only for certain types, and only by hacking the system catalogs, which is a procedure fraught with danger. i.e. backup all your data, then proceed with caution. Generally, it's best to create a new column and put the data in there and drop the old column. Note you can do this in a transaction, so you can roll it back should you realize you've made some kind of error. begin; alter table t1 add column c1 int8; update t1 set c1=c2; alter table t1 drop column c2; commit; vacuum;