Discussion:
Location of a new column
(too old to reply)
Terry Hampton
2004-04-08 12:36:37 UTC
Permalink
All,

I thought this was answered before, but I
could not find anything in my saved email.

I need to ALTER a table to add a new column.
I want the new column to be between two existing
columns, however. Didn't I see mention of
an "AFTER" parameter that specified the location
in the table where the new column should be
placed ? Maybe not .......... How then,
can I specify the location within the table, of
new column ?

7.3 & RH Linux



Many thanks !

Terry
--
Terry L. Hampton
Project Manager
LimaCorp, LLC www.limacorp.com
513.587.1874



---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org
Stephan Szabo
2004-04-08 13:55:16 UTC
Permalink
Post by Terry Hampton
I thought this was answered before, but I
could not find anything in my saved email.
I need to ALTER a table to add a new column.
I want the new column to be between two existing
columns, however. Didn't I see mention of
an "AFTER" parameter that specified the location
in the table where the new column should be
placed ? Maybe not .......... How then,
can I specify the location within the table, of
new column ?
AFAIK, you can't using add column. It currently does no more than the
SQL92/99 spec requires in that respect (which is put the column at the
end).

About all you can do to put it somewhere else is a sequence with a new
table, copying data and renaming (and fixing constraints).

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org
Robert Treat
2004-04-12 21:44:31 UTC
Permalink
Post by Stephan Szabo
Post by Terry Hampton
I thought this was answered before, but I
could not find anything in my saved email.
I need to ALTER a table to add a new column.
I want the new column to be between two existing
columns, however. Didn't I see mention of
an "AFTER" parameter that specified the location
in the table where the new column should be
placed ? Maybe not .......... How then,
can I specify the location within the table, of
new column ?
AFAIK, you can't using add column. It currently does no more than the
SQL92/99 spec requires in that respect (which is put the column at the
end).
About all you can do to put it somewhere else is a sequence with a new
table, copying data and renaming (and fixing constraints).
IIRC this option is available in 7.5. At least I seem to remember some
(Chris K-L) posting a patch and it getting committed. You could check
the developers docs to verify I suppose.

Robert Treat
--
Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL


---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html
Tom Lane
2004-04-12 22:36:09 UTC
Permalink
Post by Robert Treat
Post by Stephan Szabo
AFAIK, you can't using add column. It currently does no more than the
SQL92/99 spec requires in that respect (which is put the column at the
end).
IIRC this option is available in 7.5.
No, there has been some discussion but no move to implement it.

AFAIR there is no reasonable way to implement it without breaking apps
that depend on the existing semantics of pg_attribute.attnum :-(.
Check the pghackers archives if you want to know more.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Loading...