Updated on 2024-05-07 GMT+08:00

Boolean Types

Table 1 lists the Boolean types supported by GaussDB.

Table 1 Boolean type

Name

Description

Storage Space

Value

BOOLEAN

Boolean

1 byte

  • true
  • false
  • null: unknown
  • Valid literal values for the "true" state include:

    TRUE, 't', 'true', 'y', 'yes', '1', 'TRUE', true, on, and all non-zero values.

  • Valid literal values for the "false" state include:

    FALSE, 'f', 'false', 'n', 'no', '0', 0, 'FALSE', false, and off.

TRUE and FALSE are standard expressions, compatible with SQL statements.

Examples

Boolean values are displayed using the letters t and f.

 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
-- Create a table.
gaussdb=# CREATE TABLE bool_type_t1  
(
    BT_COL1 BOOLEAN,
    BT_COL2 TEXT
)DISTRIBUTE BY HASH(BT_COL2);

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

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

-- View data.
gaussdb=# SELECT * FROM bool_type_t1;
 bt_col1 | bt_col2 
---------+---------
 t       | sic est
 f       | non est
(2 rows)

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

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