I've tried the following, but I was unsuccessful:
ALTER TABLE person ALTER COLUMN dob POSITION 37;
"Alter column position" in the PostgreSQL Wiki says:
PostgreSQL currently defines column order based on the
attnum
column of thepg_attribute
table. The only way to change column order is either by recreating the table, or by adding columns and rotating data until you reach the desired layout.
You can also define a VIEW
that specifies the order of columns how you like it, without changing the physical position of the column in the base table.
That's pretty weak, but this is not a knock against PostgreSQL. In their defense, standard SQL has no solution for repositioning a column, and some other SQL implementations besides PostgreSQL follow this standard.
SQL implementations that support changing the ordinal position of a column are defining an non-standard extension to SQL syntax.