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

时间:2024-01-23 20:08:49

示例

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

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

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

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

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

--删除表。
postgres=# DROP TABLE bool_type_t1;
support.huaweicloud.com/devg-v1-gaussdb/gaussdb_devg_0365.html