本文主要是介绍PostgreSql 报错ERROR: cannot cast type smallint to boolean,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
一、现象
--表修改字段类型时报错
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
这篇关于PostgreSql 报错ERROR: cannot cast type smallint to boolean的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!