X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 34F99329E3B for ; Wed, 15 Sep 2004 13:25:27 +0100 (BST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 01930-07 for ; Wed, 15 Sep 2004 12:25:18 +0000 (GMT) Received: from ucsns.ucs.co.za (ucs.co.za [196.23.43.2]) by svr1.postgresql.org (Postfix) with ESMTP id 7ADCA329DF7 for ; Wed, 15 Sep 2004 13:25:15 +0100 (BST) Received: from localhost (localhost.localdomain [127.0.0.1]) by ucsns.ucs.co.za (Postfix) with ESMTP id 2D6EE2BD66 for ; Wed, 15 Sep 2004 14:24:44 +0200 (SAST) Received: from ucsns.ucs.co.za ([127.0.0.1]) by localhost (ucsns.ucs.co.za [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 28181-02 for ; Wed, 15 Sep 2004 14:24:34 +0200 (SAST) Received: from ucspost.ucs.co.za (mailgw1.ucs.co.za [196.23.43.253]) by ucsns.ucs.co.za (Postfix) with ESMTP id F0EBF2BD6B for ; Wed, 15 Sep 2004 14:24:33 +0200 (SAST) Received: from jhb.ucs.co.za (jhb.ucs.co.za [172.31.1.3]) by ucspost.ucs.co.za (Postfix) with ESMTP id 78AA4DA282 for ; Wed, 15 Sep 2004 14:24:52 +0200 (SAST) Received: from svb.ucs.co.za (svb.ucs.co.za [172.31.1.148]) by jhb.ucs.co.za (Postfix) with SMTP id 6D09F976CB for ; Wed, 15 Sep 2004 14:24:45 +0200 (SAST) Date: Wed, 15 Sep 2004 14:24:45 +0200 From: Stef To: pgsql-sql@postgresql.org Subject: Preserving column order when recreating table. Message-Id: <20040915142445.06b60e3e@svb.ucs.co.za> X-Mailer: Sylpheed-Claws 0.9.12 (GTK+ 1.2.10; i386-pc-linux-gnu) User-Agent: sillypheed-claws (anti-aliased) X-Face: GFoC95e6r)_TTG>n~=uFLojP=O~4W@Ms]>:.DMm/')(z3\Mwj^XP@? Q:3";lD.OM1"^mDu}2NJ@US:)dO:U*iY5EM50&Tx. X-Operating-System: sid X-X-X: _-^-_ Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at ucs.co.za X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200409/105 X-Sequence-Number: 18951 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 Stefan