在Db2中处理BOOLEAN值的最佳方法是什么? [英] What is the best way to handle BOOLEAN values in Db2?
问题描述
数据库
Db2
场景
我有一列必须为true或false。我发现了两个指向如何实现这一目标的资源。但是,当我将它们放在一起时会出错。
I have a column that needs to be true or false. I have found two sources that point to how to achieve this; however, when I bring them together I get an error.
- Boolean values
- Casting between data types
当前解决方案
CREATE TABLE USERS
(
ID INT NOT NULL,
.
.
.
IS_LOCKED SMALLINT NOT NULL WITH DEFAULT 0,
PRIMARY KEY(ID)
);
选择U.ID,CAST(U.IS_LOCKED AS BOOLEAN)作为IS_LOCKED来自用户U
错误:数据类型为 SYSIBM.SMALLINT的值不能为CAST键入 SYSIBM .BOOLEAN
问题
如何我在Db2中使用BOOLEAN吗?
How can I use BOOLEANs in Db2?
推荐答案
您提供了指向Db2 11.1手册的链接,以及第二个指向DB2 9.7手册的链接。 。兹为您解答。 Db2 11.1.1.1中将BOOLEAN作为列数据类型支持,但DB2 9.7中不支持BOOLEAN。
You give a link to the Db2 11.1 manuals, and a second link to the DB2 9.7 manuals. Hereby lies your answer. BOOLEAN is supported as a column data type in Db2 11.1.1.1, but not in DB2 9.7.
现在可以将BOOLEAN数据类型用于表列和表达式结果。这增强了与其他关系数据库管理系统的兼容性
The BOOLEAN data type can now be used for table columns and for expression results. This enhances compatibility with other relational database management systems
这篇关于在Db2中处理BOOLEAN值的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!