一、现象
--表修改字段类型时报错
postgres=# alter table t alter sex type boolean using sex::boolean;
ERROR: cannot cast type smallint to boolean
LINE 1: alter table t alter sex type boolean using sex::boolean;
二、处理
smallint 类型需先转为 int 类型,再转为布尔类型。
postgres=# alter table t alter sex type int using sex::int;
ALTER TABLE
postgres=# alter table t alter sex type boolean using sex::boolean;
ALTER TABLE