Upgrading a varchar column to enum type in postgresql

前端 未结 3 1627
别跟我提以往
别跟我提以往 2020-12-09 09:15

We have a varchar column in a table, that we need to upgrade to enum type.

All the values in the varchar column are valid values in the enumeration. There is no null

3条回答
  •  抹茶落季
    2020-12-09 10:04

    Got it.

    ALTER TABLE tableName
       ALTER COLUMN varcharColumn TYPE enum_type
        USING varcharColumn::enum_type
    

    will update it successfully.

提交回复
热议问题