Postgresql change column type from int to UUID

后端 未结 7 1617
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-23 13:26

I\'d like to change the column type from an int to a uuid. I am using the following statement

ALTER TABLE tableA ALTER COLUMN colA          


        
7条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-23 14:15

    In PostgreSQL 9.3 you can do this:

    ALTER TABLE "tableA" ALTER COLUMN "ColA" SET DATA TYPE UUID USING "ColA"::UUID;
    

    And cast the type of data to UUID and this will avoid the error message.

提交回复
热议问题