From: Stef <svb@ucs.co.za>
To: Andrew Sullivan <ajs@crankycanuck.ca>
Cc: pgsql-sql@postgresql.org
Subject: Re: Preserving column order when recreating table.
Date: Wed, 15 Sep 2004 16:22:01 +0200
Message-ID: <20040915162201.13be5102@svb.ucs.co.za> (raw)
In-Reply-To: <20040915131930.GA28290@phlogiston.dyndns.org>
References: <20040915142445.06b60e3e@svb.ucs.co.za>
<20040915131930.GA28290@phlogiston.dyndns.org>
Andrew Sullivan mentioned :
=> I'm not sure why you want to do the former, but in any case, it's
Because lazy people write inserts without specifying column names.
=> possible by creating a new table which has things the way you want;
=> select all the old data from the old table into the new table (using
=> the column names to get everything in the order you like, of course),
I like this idea, but each database may have a different table definition
for the same table, and if I want to automate this, I need to figure out the
column names on the fly.
=> and then rename the old table, rename the new table to the old table
=> name, and drop the old table if you like.
I think I've got the solution now. I'll do it in two steps.
Fist add/drop all the columns that are not there/not supposed to be there,
and in the second step do what you suggested.
Thanks!!
Kind Regards
Stefan
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 using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: svb@ucs.co.za, ajs@crankycanuck.ca
Subject: Re: Preserving column order when recreating table.
In-Reply-To: <20040915162201.13be5102@svb.ucs.co.za>
* 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