云数据库 GAUSSDB-布尔类型:示例

时间:2023-11-15 14:50:00

示例

显示用字母t和f输出Boolean值。

 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
--创建表。
openGauss=# CREATE TABLE bool_type_t1  
(
    BT_COL1 BOOLEAN,
    BT_COL2 TEXT
)DISTRIBUTE BY HASH(BT_COL2);

--插入数据。
openGauss=# INSERT INTO bool_type_t1 VALUES (TRUE, 'sic est');

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

--查看数据。
openGauss=# SELECT * FROM bool_type_t1;
 bt_col1 | bt_col2 
---------+---------
 t       | sic est
 f       | non est
(2 rows)

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

--删除表。
openGauss=# DROP TABLE bool_type_t1;
support.huaweicloud.com/distributed-devg-v2-gaussdb/gaussdb_v5r2c10_0319.html