BOOLEAN data type

Synopsis

Use the BOOLEAN data type 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 the PRIMARY KEY.
  • Columns of type BOOLEAN can be set, inserted, and compared.
  • In WHERE and IF clause, BOOLEAN columns cannot be used as a standalone expression. They must be compared with either true or false. For example, WHERE boolean_column = TRUE is valid while WHERE boolean_column is not.
  • Implicitly, BOOLEAN is neither comparable nor convertible to any other data types.

Examples

ycqlsh:example> CREATE TABLE tasks (id INT PRIMARY KEY, finished BOOLEAN);
ycqlsh:example> INSERT INTO tasks (id, finished) VALUES (1, false);
ycqlsh:example> INSERT INTO tasks (id, finished) VALUES (2, false);
ycqlsh:example> UPDATE tasks SET finished = true WHERE id = 2;
ycqlsh:example> SELECT * FROM tasks;
id | finished
----+----------
  2 |     True
  1 |    False

See also