Re: Add Column BEFORE/AFTER another column - Mailing list pgsql-general

From Bill Moran
Subject Re: Add Column BEFORE/AFTER another column
Date
Msg-id 20070824171118.6e37a202.wmoran@potentialtech.com
Whole thread Raw
In response to Add Column BEFORE/AFTER another column  (Matthew <mboehm@voilaip.com>)
Responses Re: Add Column BEFORE/AFTER another column  (Matthew <mboehm@voilaip.com>)
List pgsql-general
In response to Matthew <mboehm@voilaip.com>:

> Hi gang,
>  In MySQL it is possible to add a column before/after another column. I
> have not been able to find such syntax in the Postgres manual. Does this
>  ability exist?

It does not.

> Is my only solution to create a new table with the new column, copy the
> data, delete the old table and rename the new one?

The fact that you're asking this question is a hint that you're using
unsafe coding practices that may bite you at some point.  The order
of columns is not guaranteed to be the same as when you do CREATE
TABLE, it's just coincidence that they usually are.

To get your columns in a specific order, specify the column names in
that order in your SELECT statement.  The SQL standard doesn't provide
for any other way to guarantee column order, and neither does Postgres.

--
Bill Moran
http://www.potentialtech.com

pgsql-general by date:

Previous
From: Matthew
Date:
Subject: Add Column BEFORE/AFTER another column
Next
From: Matthew
Date:
Subject: Re: Add Column BEFORE/AFTER another column