Re: RE : full featured alter table? - Mailing list pgsql-general

From Tom Lane
Subject Re: RE : full featured alter table?
Date
Msg-id 6454.1055794855@sss.pgh.pa.us
Whole thread Raw
In response to Re: RE : full featured alter table?  (Sven Köhler <skoehler@upb.de>)
Responses Re: RE : full featured alter table?  (Sven Köhler <skoehler@upb.de>)
Re: RE : full featured alter table?  (Bruce Momjian <pgman@candle.pha.pa.us>)
List pgsql-general
=?ISO-8859-1?Q?Sven_K=F6hler?= <skoehler@upb.de> writes:
> perhaps we could also think about a
> ALTER TABLE <table> POSITIONS <column1>,<column2>,...

You could invent a syntax that supports both use cases, along the lines
of

ALTER ... POSITION <i> <column1> [ , <column2> ... ]

with the meaning that the named columns are inserted sequentially between
positions i-1 and i, moving them from wherever they were, and leaving
all not-mentioned columns in their existing relative order.  This
degenerates to the same as your first proposal if one column is named,
and at the other extreme allows all the columns to be re-ordered in one
command.

It could get a little confusing if some of the named columns previously
occupied positions less than <i>.  I'd suggest the following
more-concrete specification:

1. <i> must be in the range 1 to (<number of columns in table> -
   <number of columns named in statement> + 1).
2. After the ALTER, the named columns have ordinal positions <i>, <i+1>,
   etc.
3. Any columns not named are placed into the remaining slots (1..i-1
   and i+nnamedcols..ntablecols) in the same relative order they had
   before.

            regards, tom lane

pgsql-general by date:

Previous
From: "scott.marlowe"
Date:
Subject: Re: postgreSQL on NAS/SAN?
Next
From: Tom Lane
Date:
Subject: Re: Postgres performance comments from a MySQL user