From: Tom Lane <tgl@sss.pgh.pa.us>
To: Zot O'Connor <zot@zotconsulting.com>
Cc: postgres sql <pgsql-sql@hub.org>
Subject: Re: [SQL] Converting an existing table?
Date: Sat, 18 Sep 1999 10:23:32 -0400
Message-ID: <13298.937664612@sss.pgh.pa.us> (raw)
In-Reply-To: <37E2ACC7.E2513AD9@zotconsulting.com>
"Zot O'Connor" <zot@zotconsulting.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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: tgl@sss.pgh.pa.us, zot@zotconsulting.com, pgsql-sql@hub.org
Subject: Re: [SQL] Converting an existing table?
In-Reply-To: <13298.937664612@sss.pgh.pa.us>
References: <37E2ACC7.E2513AD9@zotconsulting.com> <13298.937664612@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox