Skip site navigation (1) Skip section navigation (2)

Preserving column order when recreating table.

From: Stef <svb(at)ucs(dot)co(dot)za>
To: pgsql-sql(at)postgresql(dot)org
Subject: Preserving column order when recreating table.
Date: 2004-09-15 12:24:45
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-sql
Hi all,

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)

The complication comes in when the newly created table
could have extra (new) columns, or its column order is not the
same as the original table's, but the corresponding column 
names are the same.

My question is : 
Is it possible to do this in DML/DDL ?
That is, dumping  the data,  dropping the table,
recreating the table, and reimporting the data in the correct order ?

I've tried different things, but I cannot write SQL to do this.
I know it's easy from a script, but I don't have any other type 
of access to the database servers.

Kind Regards


pgsql-sql by date

Next:From: Andrew SullivanDate: 2004-09-15 13:19:30
Subject: Re: Preserving column order when recreating table.
Previous:From: Sanjay SinghDate: 2004-09-15 09:22:25
Subject: Re: sleep function

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group