PostgreSQL query to rename and change column type with single query

前端 未结 2 1912
执笔经年
执笔经年 2021-01-31 02:16

In PostgreSQL if I need to rename and change a column data type, I run two separate queries to do so.

To rename:

AL         


        
2条回答
  •  无人及你
    2021-01-31 02:39

    PostgreSQL: Alter table column name and data-type:

    ALTER TABLE  
       ALTER [ COLUMN ] column [ SET DATA ] TYPE data_type [ COLLATE collation ] [ USING expression ]
      RENAME [ COLUMN ] column TO new_column;
    

    See ALTER TABLE.

提交回复
热议问题