Re: Preserving column order when recreating table. - Mailing list pgsql-sql

From Stef
Subject Re: Preserving column order when recreating table.
Date
Msg-id 20040915162201.13be5102@svb.ucs.co.za
Whole thread Raw
In response to Re: Preserving column order when recreating table.  (Andrew Sullivan <ajs@crankycanuck.ca>)
Responses Re: Preserving column order when recreating table.
Re: Preserving column order when recreating table.
List pgsql-sql
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


pgsql-sql by date:

Previous
From: Andrew Sullivan
Date:
Subject: Re: Preserving column order when recreating table.
Next
From: Andrew Sullivan
Date:
Subject: Re: Preserving column order when recreating table.