If you want this just for looks, I find it easier to keep a view per each table with desired order of columns, and select from it instead of the table.
create table my_table (
create view view_my_table as
select id, name, created_date from my_table;
-- adding a new column
begin;
alter table my_table add column email varchar(255);
drop view view_my_table;
create view view_my_table as
select id, name, email, created_date from my_table;
commit;
For all other purposes (like insert, union) it is better to always specify the column list.
-- bad
insert into my_table values (...);
(select * from my_table)
union all
(select * from my_table);
-- good
insert into my_table (id, name, email, created_date) values (...);
(select id, name, email, created_date from my_table)
union all
(select id, name, email, created_date from my_table);
viewthat show's it in that order... technically the position of the column shouldn't matter as you can define them in any order in a query... and you generally shouldn't be doing aselect *– xenoterracide Jun 12 '11 at 16:00\d mytableinpsqland check with my fields in my source code e.g. both in Java and JavaScript. – Jonas Jun 12 '11 at 16:45createdof type Timestamp. This is a kind of meta-column, and it helps if that is the last column in every table, even after adding columns to the table. – Jonas Jun 12 '11 at 16:48psql -Eswitch to see the actual query) – Jack Douglas Jun 13 '11 at 08:06