How do I alter the position of a column in a PostgreSQL database table?

前端 未结 9 1556
[愿得一人]
[愿得一人] 2020-11-30 00:25

I\'ve tried the following, but I was unsuccessful:

ALTER TABLE person ALTER COLUMN dob POSITION 37;
9条回答
  •  天命终不由人
    2020-11-30 00:48

    In PostgreSQL, while adding a field it would be added at the end of the table. If we need to insert into particular position then

    alter table tablename rename to oldtable;
    create table tablename (column defs go here);
    insert into tablename (col1, col2, col3) select col1, col2, col3 from oldtable;
    

提交回复
热议问题