pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andrew Sullivan <ajs@crankycanuck.ca>
To: pgsql-sql@postgresql.org
Subject: Re: Preserving column order when recreating table.
Date: Wed, 15 Sep 2004 09:19:30 -0400
Message-ID: <20040915131930.GA28290@phlogiston.dyndns.org> (raw)
In-Reply-To: <20040915142445.06b60e3e@svb.ucs.co.za>
References: <20040915142445.06b60e3e@svb.ucs.co.za>

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



view thread (6+ messages)  latest in thread

Message-ID: <20040915131930.GA28290@phlogiston.dyndns.org>
Permalink:  ../20040915131930.GA28290@phlogiston.dyndns.org/
Also on:    postgresql.org/message-id/20040915131930.GA28290@phlogiston.dyndns.org

 · 

reply

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: ajs@crankycanuck.ca
  Subject: Re: Preserving column order when recreating table.
  In-Reply-To: <20040915131930.GA28290@phlogiston.dyndns.org>

* 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