[lug] Postgres Alter table
Calvin Dodge
caldodge at fpcc.net
Thu Jul 12 15:21:55 MDT 2001
On Thu, Jul 12, 2001 at 01:16:08AM -0600, John Starkey wrote:
> Does anyone know how to alter a table type in postgres? I've been sitting
> on this one for a while, checked the manual several times. I see that you
> can add constraints but I don't see anything about types.
>
> I've got an int value I need to make real.
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?
Calvin
--
Calvin Dodge
Certified Linux Bigot (tm)
http://www.caldodge.fpcc.net
More information about the LUG
mailing list