Re: Reordering columns in a table

From: John McCawley <nospam(at)hardgeus(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Reordering columns in a table
Date: 2006-01-06 19:19:36
Message-ID: 43BEC2C8.1070003@hardgeus.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-general

I would certainly never have any of my normal application code depend on
the ordering of columns. My desire for column ordering is strictly for
administration purposes, keeping the visual clarity of the datamodel,
and ensuring that the visual datamodel is consistent with what is
actually in the database.

When one initially designs a database, thought goes into the ordering of
columns (at least, I hope it does). In a large table it makes sense to
group like columns. Using my line of work as an example, if you are
storing the first and last names of the insured and claimant in a claim
record, one would not consciously define the table as:

insured_firstname varchar(32),
claimant_lastname varchar(32),
insured_lastname varchar(32),
claimant_firstname varchra(32)

However, in the real world, columns are often added willy-nilly as they
are needed, and it is not immediately obvious which, if any, of the
columns will be related. Later, solely for visual clarity, it is
desirable to have the ability to reorder the columns in the database. I
wouldn't depend on this ordering for a "select *" query. But I *would*
like the columns to appear in this order whenever any Postgres
administration tool asked for the column list of a table, that way it
appears the way I like in PgAdminIII, the \d command of psql, etc. etc.

John

Andreas Kretschmer wrote:

> Not really sarcastic. You can't expect the order of values in a table,
> and you can't expect the order of columns in a table.
>
> If you do a 'select * from ...', and the table-structure is changed,
> then you get problems. If you do a 'select col1, col2, col2, ... coln
> ...'), no problems.
>
> A (german) article about this (with mysql):
> http://php-faq.de/q/q-sql-select.html
>
>
> HTH, Andreas
>
>

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Andreas Kretschmer 2006-01-06 19:39:59 Re: Reordering columns in a table
Previous Message Andreas Kretschmer 2006-01-06 18:38:52 Re: Reordering columns in a table

Browse pgsql-general by date

  From Date Subject
Next Message Dann Corbit 2006-01-06 19:23:21 Re: 'Official' definition of ACID compliance?
Previous Message Scott Ribe 2006-01-06 19:10:33 Re: 'Official' definition of ACID compliance?