[lug] Postgres Alter table
John Starkey
jstarkey at advancecreations.com
Sat Jul 14 11:40:16 MDT 2001
> I don't believe you can alter or delete a field in a PostgreSQL table.
>
> You'll need to do this:
>
> alter table TABLENAME rename OLDCOLUMN to tempcolumn;
> alter table TABLENAME add column OLDCOLUMN float4;
> update TABLENAME set OLDCOLUMN=column;
>
> That should work.
>
>
> The other option is to dump the table to a text file, delete the table, edit that file to change the field's type, then reload the table.
>
> Do either of those work for you?
Thanks Calvin, Ryan, and Ralf. I ended up dumping and reloading. But I had a problem with pg_dumpall, so I took this time to upgrade and initdb for the new DB format. Then I just edited the column type in the dump file.
I've been a little spoiled by MySQL I guess :}
Thanks again.
John
More information about the LUG
mailing list