pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedConverting an existing table?
2+ messages / 2 participants
[nested] [flat]
* Converting an existing table?
@ 1999-09-17 21:04 Zot O'Connor <zot@zotconsulting.com>
0 siblings, 1 reply; 2+ messages in thread
From: Zot O'Connor @ 1999-09-17 21:04 UTC (permalink / raw)
To: postgres sql <pgsql-sql@hub.org>
I need to change the type on an existing table. From money to something
else.
What is the best way under postgres?
I could do a query and put it in a new field and then rename the old
field, and then rename the new field.
I then have the old (renamed) field hanging around. Is there a cleaner
way of doing this?
I also need to change the length of a variable length field.
--
Zot O'Connor
www.ZotConsulting.com
www.WhiteKnightHackers.com
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: [SQL] Converting an existing table?
@ 1999-09-18 14:23 Tom Lane <tgl@sss.pgh.pa.us>
parent: Zot O'Connor <zot@zotconsulting.com>
0 siblings, 0 replies; 2+ messages in thread
From: Tom Lane @ 1999-09-18 14:23 UTC (permalink / raw)
To: Zot O'Connor <zot@zotconsulting.com>; +Cc: postgres sql <pgsql-sql@hub.org>
"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
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~1999-09-18 14:23 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1999-09-17 21:04 Converting an existing table? Zot O'Connor <zot@zotconsulting.com>
1999-09-18 14:23 ` Tom Lane <tgl@sss.pgh.pa.us>
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