HomeMogDBMogDB StackUqbar
v3.0

Documentation:v3.0

Supported Versions:

Other Versions:

Boolean Data Types

Table 1 Boolean types

Name Description Storage Space Value
BOOLEAN Boolean type 1 byte - true
- false
- null (unknown)

Valid literal values for the "true" state include:

TRUE, 't', 'True', 'true', 'y', 'yes', 'Yes', '1', 'TRUE', true, and an integer ranging from 1 to 263-1 or from -1 to -263.

Valid literal values for the "false" state include:

FALSE, 'f', 'false', 'False', 'n', 'no', 'No', '0', 0, 'FALSE', and false.

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

Example

Boolean values are displayed using the letters t and f.

-- Create a table.
MogDB=# CREATE TABLE bool_type_t1
(
    BT_COL1 BOOLEAN,
    BT_COL2 TEXT
);

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

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

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

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

-- Delete the table.
MogDB=# DROP TABLE bool_type_t1;
Copyright © 2011-2024 www.enmotech.com All rights reserved.