我需要将列的数据类型从_float8更改为int4
ALTER TABLE "table" ALTER COLUMN "col" SET DATA TYPE int4;
得出column "col" cannot be cast automatically to type integer
ALTER TABLE "table" ALTER COLUMN "col" SET DATA TYPE int4 USING (col::integer);
得出cannot cast type double precision[] to integer
有什么想法吗?
答案 0 :(得分:1)
答案 1 :(得分:0)
问题是您有一个 array 。要解决此问题,您需要使用数组运算符:
ALTER TABLE "table"
ALTER COLUMN "col" SET DATA TYPE int4 USING (col[1]::integer);
Here是db <>小提琴。