Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id 03A629FB1EE for ; Wed, 4 Oct 2006 13:38:12 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 98613-03 for ; Wed, 4 Oct 2006 16:38:05 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey- Received: from alnrmhc13.comcast.net (alnrmhc13.comcast.net [206.18.177.53]) by postgresql.org (Postfix) with ESMTP id E85E69FA27F for ; Wed, 4 Oct 2006 13:38:04 -0300 (ADT) Received: from [10.0.1.4] (unknown[71.225.71.211]) by comcast.net (alnrmhc13) with SMTP id <20061004163802b1300l83joe>; Wed, 4 Oct 2006 16:38:03 +0000 User-Agent: Microsoft-Entourage/11.2.5.060620 Date: Wed, 04 Oct 2006 12:37:57 -0400 Subject: Re: i have table From: Daryl Richter To: Message-ID: Thread-Topic: [SQL] i have table Thread-Index: Acbn03JlsQy7vFPGEduNkAAWy5/eVw== In-Reply-To: Mime-version: 1.0 Content-type: text/plain; charset="US-ASCII" Content-transfer-encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200610/46 X-Sequence-Number: 26435 On 10/4/06 12:20 PM, "Aaron Bono" wrote: > On 10/4/06, Erik Jones wrote: >> >> Aaron Bono wrote: >>> On 10/4/06, *Erik Jones* > >>> wrote: >>> >>> There is one non-SQL related reason that I like to be able to order >>> columns, at least the way they are displayed whenever the table is >>> described: human comprehension. For example, I like to group all >>> keys >>> in a table before data, that includes primary as well as foreign >>> keys. >>> So, say I'm building on to an existing application and I need to do >> an >>> ALTER TABLE on an existing table to add a foreign key to an existing >>> table. I'd like that key to be listed with the other keys, but >>> presently that's not possible in a simple way and, to be honest, I >>> usually just go without as the process you've described below is too >>> prone to user (human) error when dealing with live, sensitive data >> for >>> me to want to mess with it. >>> >>> >>> Ah, but it is possible... if you use views. >>> >>> I recommend you build views and query off them. Then you can control >>> the order the columns will appear. >> Which would be great if I didn't have (many) thousands of lines of code >> that already use the tables. Besides, this is no where near a 'make or >> break' thing. It's just a matter of aesthetic preference. Ah, but it *is* a "make or break thing." I have seen more than one application crash because some developer didn't understand that columns in a relation (table) have no defined order. This (along with its sister axiom that rows have no defined order) is one of the most commonly misunderstood aspects of relational databases. > > > > So do it as needed and convert your application slowly. > > I just name my views as table_name_vw so all you have to do is modify your > queries to hit the _vw instead of just the table. That shouldn't take much > time to refactor. > > ================================================================== > Aaron Bono > Aranya Software Technologies, Inc. > http://www.aranya.com > http://codeelixir.com > ================================================================== -- Daryl http://itsallsemantics.com