RE : full featured alter table?

Ernest E Vogelsinger <ernest@vogelsinger.at>

From: Ernest E Vogelsinger <ernest@vogelsinger.at>
To: "Bruno BAGUETTE" <pgsql-ml@baguette.net>
Cc: "'Nigel J. Andrews'" <nandrews@investsystems.co.uk>, "'Sven Köhler'" <skoehler@upb.de>, <pgsql-general@postgresql.org>
Date: 2003-06-15T22:13:45Z
Lists: pgsql-general
At 23:30 15.06.2003, Bruno BAGUETTE said:
--------------------[snip]--------------------
>> If some frontende decides to display the columns in a 
>> particular order, ok, but it should store this order 
>> somewhere else, either in its own private tables, a 
>> configuration or ini file, or elsewhere. It simply doesn't 
>> belong to the database layout, or pg_attribute.
>
>I disagree, I don't like when frontends and other GUI are creating new
>tables in the database. Plus, if I use a frontend (pgAdmin, for example)
>to set the columns order, I want to get that presentation order when I
>do a SELECT * using the PostgreSQL API or using the psql frontend...
>
>So, storing the columns order in the pg_attributes table is, I think, a
>good solution. :-)
--------------------[snip]-------------------- 

This may come in handy of you're the only one using the database.

What if:
a) multiple users/developers are "maintaining" their own "private" column
ordering?
b) what happens to those (poorly written but existing) applications that
use columnless INSERTs? Will they break or what?

I don't think changing the column order in pg_attributes would be a good
thing - too much to break loose. Maybe there could be something non-SQL
conforming
   CREATE COLUMNORDER "order_name" ON TABLE "table_name" ("column", ...)
and you could use this with a SELECT extension:
   SELECT * FROM "table_name" COLUMNORDER "order_name"

but that can be easily done using views:
   CREATE VIEW "viewname" AS SELECT (col3, col5, col2) FROM "table_name"

Well, views are read-only unless you're using an appropriate rule.


-- 
   >O     Ernest E. Vogelsinger
   (\)    ICQ #13394035
    ^     http://www.vogelsinger.at/