Updated on 2025-10-23 GMT+08:00

Boolean Types

BOOLEAN data type is used to store Boolean values true and false. The BOOLEAN or BOOL type is a synonym of the TINYINT type. Values other than 1 and 0 can be inserted into the BOOL or BOOLEAN column. Table 1 lists the Boolean types supported by M-compatible databases.

Table 1 Boolean types

Name

Description

Storage Space

Value

BOOLEAN

BOOL

Boolean. Value range: [–128, 127]

1 byte

  • TRUE, 1, true, and all non-zero numeric values.
  • FALSE, 0, false.
  • null.

Boolean values true and false are recommended in SQL.

Examples

Boolean values are displayed using the numbers 1 and 0.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
-- Create a table.
m_db=# CREATE TABLE bool_type_t1  
(
    BT_COL1 BOOLEAN,
    BT_COL2 TEXT
);

-- Insert data.
m_db=# INSERT INTO bool_type_t1 VALUES (TRUE, 'sic est'); 

m_db=# INSERT INTO bool_type_t1 VALUES (FALSE, 'non est');

m_db=# INSERT INTO bool_type_t1 VALUES (123, 'sic est');

-- View data.
m_db=# SELECT * FROM bool_type_t1;
 bt_col1 | bt_col2
---------+---------
 1       | sic est
 0       | non est
 123     | sic est
(3 rows)

m_db=# SELECT * FROM bool_type_t1 WHERE bt_col1 = 't';
WARNING:  Truncated incorrect double value: 't'
 bt_col1 | bt_col2
---------+---------
 0       | non est

m_db=# SELECT * FROM bool_type_t1 WHERE bt_col1 = '123';
 bt_col1 | bt_col2
---------+---------
 123     | sic est
(1 row)

-- Drop the table.
m_db=# DROP TABLE bool_type_t1;