• Data Warehouse Service

dws
  1. Help Center
  2. Data Warehouse Service
  3. Developer Guide
  4. SQL Reference
  5. Data Types
  6. Boolean Type

Boolean Type

Table 1 Boolean type

Name

Description

Storage (GB)

Value

BOOLEAN

Boolean type

1 byte

  • true
  • false
  • null (unknown)

Valid literal values for the "true" state include:

TRUE, 't', 'true', 'y', 'yes', '1'

Valid literal values for the "false" state include:

FALSE, 'f', 'false', 'n', 'no', '0'

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

Example

Boolean values are displayed using the letters t and f.

-- Create a table.
CREATE TABLE bool_type_t1  
(
    BT_COL1 BOOLEAN,
    BT_COL2 TEXT
)  DISTRIBUTE BY HASH(BT_COL2);

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

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

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

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

-- Delete the tables.
DROP TABLE bool_type_t1;