Re: [SQL] Converting an existing table?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Zot O'Connor" <zot(at)zotconsulting(dot)com>
Cc: postgres sql <pgsql-sql(at)hub(dot)org>
Subject: Re: [SQL] Converting an existing table?
Date: 1999-09-18 14:23:32
Message-ID: 13298.937664612@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

"Zot O'Connor" <zot(at)zotconsulting(dot)com> writes:
> I need to change the type on an existing table. From money to something
> else.
> What is the best way under postgres?

Probably the best way at the moment is:

1. Create new table with the desired column declarations, using a
different table name.

2. Use INSERT ... SELECT ... to copy the data from old table to new,
with any transformations needed.

3. When you are happy with the contents of the new table, drop the
old table and ALTER TABLE RENAME to rename the new table to the
original table name.

regards, tom lane

Browse pgsql-sql by date

  From Date Subject
Next Message Margarita Barvinok 1999-09-20 14:57:54 Where to find the patch?
Previous Message Molnar Laszlo 1999-09-18 08:39:29 [SQL] input function problem for user type array