I am using PostgreSQL. Can I change the order of columns?

239 Views Asked by At

I know that the order is meaningless.

But I want to adjust the order for readability.

Can not change the order of columns in the postgresql?

I am using postico for mac. Thanks.

1

There are 1 best solutions below

2
On BEST ANSWER

You could re-create the table with your ordering du jour. However, probably the simplest method is just to query the table with the columns you want:

select col3, col1, col4, . . .
from t;

You can wrap this in a view so you can use it anytime in the future:

create view v_t as
    select col3, col1, col4, . . .
    from t;