BOOLEAN type
Synopsis
BOOLEAN
data type is used to specify values of either true
or false
.
Syntax
type_specification ::= BOOLEAN
boolean_literal ::= TRUE | FALSE
Semantics
- Columns of type
BOOLEAN
cannot be part of thePRIMARY KEY
. - Columns of type
BOOLEAN
can be set, inserted, and compared. - In
WHERE
andIF
clause,BOOLEAN
columns cannot be used as a standalone expression. They must be compared with eithertrue
orfalse
. For example,WHERE boolean_column = TRUE
is valid whileWHERE boolean_column
is not. - Implicitly,
BOOLEAN
is neither comparable nor convertible to any other data types.
Examples
cqlsh:example> CREATE TABLE tasks (id INT PRIMARY KEY, finished BOOLEAN);
cqlsh:example> INSERT INTO tasks (id, finished) VALUES (1, false);
cqlsh:example> INSERT INTO tasks (id, finished) VALUES (2, false);
cqlsh:example> UPDATE tasks SET finished = true WHERE id = 2;
cqlsh:example> SELECT * FROM tasks;
id | finished
----+----------
2 | True
1 | False
See also
当前内容版权归 YugabyteDB 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 YugabyteDB .