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 6038C329DC4 for ; Wed, 15 Sep 2004 15:42:23 +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 55782-07 for ; Wed, 15 Sep 2004 14:42:14 +0000 (GMT) Received: from smtp104.rog.mail.re2.yahoo.com (smtp104.rog.mail.re2.yahoo.com [206.190.36.82]) by svr1.postgresql.org (Postfix) with SMTP id 11983329D8C for ; Wed, 15 Sep 2004 15:42:13 +0100 (BST) Received: from unknown (HELO phlogiston.dydns.org) (a.sullivan@rogers.com@65.49.125.184 with login) by smtp104.rog.mail.re2.yahoo.com with SMTP; 15 Sep 2004 14:42:13 -0000 Received: by phlogiston.dydns.org (Postfix, from userid 1000) id 2B06740E2; Wed, 15 Sep 2004 10:42:12 -0400 (EDT) Date: Wed, 15 Sep 2004 10:42:12 -0400 From: Andrew Sullivan To: pgsql-sql@postgresql.org Subject: Re: Preserving column order when recreating table. Message-ID: <20040915144212.GA28600@phlogiston.dyndns.org> Mail-Followup-To: pgsql-sql@postgresql.org References: <20040915142445.06b60e3e@svb.ucs.co.za> <20040915131930.GA28290@phlogiston.dyndns.org> <20040915162201.13be5102@svb.ucs.co.za> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040915162201.13be5102@svb.ucs.co.za> User-Agent: Mutt/1.5.6+20040722i 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/108 X-Sequence-Number: 18954 On Wed, Sep 15, 2004 at 04:22:01PM +0200, Stef wrote: > Andrew Sullivan mentioned : > => I'm not sure why you want to do the former, but in any case, it's > Because lazy people write inserts without specifying column names. Ugh. Sorry to say so, but this sounds to me really a lot like the cure is worse than the disease. The answer to "Bob did something incredibly stupid" is not "We'll bend ourselves into contortions to support it." (This is not to say I don't sympathise. You wouldn't believe how much I do.) > => 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), > > I like this idea, but each database may have a different table definition > for the same table, and if I want to automate this, I need to figure out the > column names on the fly. That's a little trickier, but you could figure it out with some queries from pg_class and pg_attribute. > Thanks!! No problem, but I think you need to have a long talk with your developers. Possibly while holding a baseball bat or something. Furrfu. This no-column-names thing is bound to bite you some day, and probably in tender bits where such bites would be unpleasant. A -- Andrew Sullivan | ajs@crankycanuck.ca This work was visionary and imaginative, and goes to show that visionary and imaginative work need not end up well. --Dennis Ritchie