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

From Andrew Sullivan
Subject Re: Preserving column order when recreating table.
Date
Msg-id 20040915131930.GA28290@phlogiston.dyndns.org
Whole thread Raw
In response to Preserving column order when recreating table.  (Stef <svb@ucs.co.za>)
Responses Re: Preserving column order when recreating table.  (Stef <svb@ucs.co.za>)
List pgsql-sql
On Wed, Sep 15, 2004 at 02:24:45PM +0200, Stef wrote:

> I'm struggling with a situation where I 
> want to recreate a table (in more than 30 databases) to
> fix the column order (attnum sequence) and in another case,
> fix different definitions for the same column in a table e.g. 
> amount numeric(16,2) 
> in stead of :
> amount numeric(16,5)

I'm not sure why you want to do the former, but in any case, it's
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),
and then rename the old table, rename the new table to the old table
name, and drop the old table if you like.

A 

-- 
Andrew Sullivan  | ajs@crankycanuck.ca
The fact that technology doesn't work is no bar to success in the marketplace.    --Philip Greenspun


pgsql-sql by date:

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