从带有BIT列的HSQLDB表中选择 [英] Selecting from a HSQLDB table with a BIT column
问题描述
我有一个表,该表的列的数据类型为bit
.
I have a table with a column of data type bit
.
> CREATE MEMORY TABLE Dummy (name varchar(10), flag bit)
> INSERT INTO Dummy VALUES ('foo', 1)
> INSERT INTO Dummy VALUES ('bar', 0)
> INSERT INTO Dummy VALUES ('foo2', true)
> INSERT INTO Dummy VALUES ('bar2', false)
> select name from Dummy where flag=1
foo2
> select name from Dummy where flag=true
foo2
为什么我没有得到foo
? 0
和1
位如何转换为布尔值?似乎两者都是错误的,我无法区分它们.
Why don't I get foo
? How are the 0
and 1
bits converted to booleans? It seems that both are false and I can't differentiate between them.
(顺便说一下,该表基于我在Sybase中拥有的一个.位1和0正确地转换为true和false.)
(By the way, this table is based on one I have in Sybase. The bits 1 and 0 are translated to true and false correctly.)
推荐答案
这与您对HSQLDB 2.2.5的预期一样工作,返回两行.
This works as you would expect with HSQLDB 2.2.5, returning two rows.
HSQLDB 2.x直接支持BIT类型并存储位值.可以存储值B'0'和B'1'.它将TRUE和FALSE分别转换为1和0.整数值0和1也转换为位.
HSQLDB 2.x supports the BIT type directly and stores bit values. Values B'0' and B'1' can be stored. It translates TRUE and FALSE into 1 and 0 respectively. Integer values 0 and 1 are also translated into bits.
在定义该列后,HSQLDB 1.8会将BIT转换为BOOLEAN.从整数转换可能并不总是有效.
HSQLDB 1.8 translates BIT into BOOLEAN as soon as the column is defined. Conversion from integer may not always work.
这篇关于从带有BIT列的HSQLDB表中选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!