Search code examples
postgresqlpostico

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


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.


Solution

  • 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;