Search Postgresql Archives

Re: Add Column BEFORE/AFTER another column

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In response to Matthew <mboehm@xxxxxxxxxxx>:

> 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

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

               http://archives.postgresql.org/

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux