Re: Preserving column order when recreating table.

From: Andrew Sullivan <ajs(at)crankycanuck(dot)ca>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: Preserving column order when recreating table.
Date: 2004-09-15 13:19:30
Message-ID: 20040915131930.GA28290@phlogiston.dyndns.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)crankycanuck(dot)ca
The fact that technology doesn't work is no bar to success in the marketplace.
--Philip Greenspun

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Stef 2004-09-15 14:22:01 Re: Preserving column order when recreating table.
Previous Message Stef 2004-09-15 12:24:45 Preserving column order when recreating table.