SELECT

功能描述

SELECT用于从表或视图中取出数据。

SELECT语句就像叠加在数据库表上的过滤器,利用SQL关键字从数据表中过滤出用户需要的数据。

注意事项

  • 对比原openGauss的SELECT语法,新增了WHERE子句下的sounds like语法。

  • 新增join不带on/using,效果与cross join一致。

  • 新增PARTITION子句可指定多个分区。

  • 新增UNION子句列如果没有相似的数据类型,会采取转换为text类型的方式进行处理。

  • 新增FROM DUAL 语法,含义等同于不写FROM子句,是为了满足那些要求所有SELECT语句都应该包含FROM的情况。

语法格式

  • 查询数据
  1. [ WITH [ RECURSIVE ] with_query [, ...] ]
  2. SELECT [/*+ plan_hint */] [ ALL | DISTINCT [ ON ( expression [, ...] ) ] ]
  3. { * | {expression [ [ AS ] output_name ]} [, ...] }
  4. [ FROM from_item [, ...] ]
  5. [ WHERE condition ]
  6. [ [ START WITH condition ] CONNECT BY [NOCYCLE] condition [ ORDER SIBLINGS BY expression ] ]
  7. [ GROUP BY grouping_element [, ...] ]
  8. [ HAVING condition [, ...] ]
  9. [ WINDOW {window_name AS ( window_definition )} [, ...] ]
  10. [ { UNION | INTERSECT | EXCEPT | MINUS } [ ALL | DISTINCT ] select ]
  11. [ ORDER BY {expression [ [ ASC | DESC | USING operator ] | nlssort_expression_clause ] [ NULLS { FIRST | LAST } ]} [, ...] ]
  12. [ LIMIT { [offset,] count | ALL } ]
  13. [ OFFSET start [ ROW | ROWS ] ]
  14. [ FETCH { FIRST | NEXT } [ count ] { ROW | ROWS } ONLY ]
  15. [ {FOR { UPDATE | NO KEY UPDATE | SHARE | KEY SHARE } [ OF table_name [, ...] ] [ NOWAIT ]} [...] ];
  • 其中指定查询源from_item为:

    1. {[ ONLY ] table_name [ * ] [ partition_clause ] [ [ AS ] alias [ ( column_alias [, ...] ) ] ]
    2. [ TABLESAMPLE sampling_method ( argument [, ...] ) [ REPEATABLE ( seed ) ] ]
    3. [TIMECAPSULE {TIMESTAMP|CSN} expression]
    4. |( select ) [ AS ] alias [ ( column_alias [, ...] ) ]
    5. |with_query_name [ [ AS ] alias [ ( column_alias [, ...] ) ] ]
    6. |function_name ( [ argument [, ...] ] ) [ AS ] alias [ ( column_alias [, ...] | column_definition [, ...] ) ]
    7. |function_name ( [ argument [, ...] ] ) AS ( column_definition [, ...] )
    8. |from_item [ NATURAL ] join_type from_item [ ON join_condition | USING ( join_column [, ...] ) ]}
  • 其中不写FROM 子句的情况等价于:

    1. FROM DUAL
  • 其中group子句为:

    1. ( )
    2. | expression
    3. | ( expression [, ...] )
    4. | rollup_clause
    5. | CUBE ( { expression | ( expression [, ...] ) } [, ...] )
    6. | GROUPING SETS ( grouping_element [, ...] )
  • 其中指定分区partition_clause为:

    1. PARTITION { ( partition_name [, ...] ) |
    2. FOR ( partition_value [, ...] ) }

    SELECT - 图1 说明: 指定分区只适合分区表。

    rollup_clause子句为:

    1. ROLLUP ( { expression | ( expression [, ...] ) } [, ...] )
    2. | { expression | ( expression [, ...] ) } WITH ROLLUP
  • JOIN语法

  1. [JOIN | INNER JOIN] {ON join_condition | USING ( join_column [, ...] ) }

参数说明

  • WHERE子句

    sounds like是condition的一种语法,用法如:column_name sounds like ‘字符’; 相当于soundex(column_name) = soundex(‘字符’)的对比结果,是一个boolean的值。用于通过soundex处理来查询满足条件的数据。

    where 子句可以包含兼容MySQL全文索引的查询语法。match(column_name [, …]) against (‘匹配字符’)也是condition的一种语法。

    1. where match(column_name [, ...]) against ('匹配字符');

    column_name可以是多列,列名之间用逗号分隔。 against()的匹配字符只能是字符内容(即全文索引支持字段类型只能是这三种char, varchar, text),不包含int, bool, 特殊字符(!,#,空格等)与正规功能。 注意: mysql的全文索引查询语法match(column_name)允许无序,但该功能底层用的是opengauss的to_tsvector(),他的要求是字段顺序必须有序(与表的字段顺序一致)。

    用于安装了dolphin插件,处于MySQL兼容性场景下的全文索引查询。其语法结构相当于

    1. to_tsvector('ngram', col_name [|| col_name]) @@ to_tsquery('字符串')
  • UNION子句 UNION计算多个SELECT语句返回行集合的并集。UNION内部的SELECT语句必须拥有相同数量的列,列如果没有相似的数据类型或者为UNKNOWN类型,会采取转换为text类型的方式进行处理。

    UNION子句有如下约束条件:

    • 除非声明了ALL子句,否则缺省的UNION结果不包含重复的行。
    • 同一个SELECT语句中的多个UNION操作符是从左向右计算的,除非用圆括弧进行了标识。
    • FOR UPDATE,FOR NO KEY UPDATE,FOR SHARE和FOR KEY SHARE不能在UNION的结果或输入中声明。

    一般表达式:

    select_statement UNION [ALL] select_statement

    • select_statement可以是任何没有ORDER BY、LIMIT、FOR UPDATE,FOR NO KEY UPDATE,FOR SHARE或FOR KEY SHARE子句的SELECT语句。
    • 如果用圆括弧包围,ORDER BY和LIMIT可以附着在子表达式里。

SELECT - 图2 说明:

涉及的其它参数说明可见SELECT

示例

  • SOUNDS LIKE子句示例:同音字段查询
  1. openGauss=# CREATE TABLE TEST(id int, name varchar);
  2. openGauss=# INSERT INTO TEST VALUES(1, 'too');
  3. openGauss=# SELECT * FROM TEST WHERE name SOUNDS LIKE 'two';
  4. id | name
  5. ----+------
  6. 1 | too
  7. (1 row)
  • SELECT GROUP BY子句中使用ROLLUP
  1. openGauss=# CREATE TABLESPACE t_tbspace ADD DATAFILE 'my_tablespace' ENGINE = test_engine;
  2. CREATE TABLESPACE
  3. openGauss=# CREATE TABLE t_with_rollup(id int, name varchar(20), area varchar(50), count int);
  4. CREATE TABLE
  5. openGauss=# INSERT INTO t_with_rollup values(1, 'a', 'A', 10);
  6. INSERT 0 1
  7. openGauss=# INSERT INTO t_with_rollup values(2, 'b', 'B', 15);
  8. INSERT 0 1
  9. openGauss=# INSERT INTO t_with_rollup values(2, 'b', 'B', 20);
  10. INSERT 0 1
  11. openGauss=# INSERT INTO t_with_rollup values(3, 'c', 'C', 50);
  12. INSERT 0 1
  13. openGauss=# INSERT INTO t_with_rollup values(3, 'c', 'C', 15);
  14. INSERT 0 1
  15. openGauss=# SELECT name, sum(count) FROM t_with_rollup GROUP BY ROLLUP(name);
  16. name | sum
  17. ------+-----
  18. a | 10
  19. b | 35
  20. c | 65
  21. | 110
  22. (4 rows)
  23. openGauss=# SELECT name, sum(count) FROM t_with_rollup GROUP BY (name) WITH ROLLUP;
  24. name | sum
  25. ------+-----
  26. a | 10
  27. b | 35
  28. c | 65
  29. | 110
  30. (4 rows)
  1. openGauss=# create table join_1(col1 int4, col2 int8);
  2. openGauss=# create table join_2(col1 int4, col2 int8);
  3. openGauss=# insert into join_1 values(1, 2), (3, 3);
  4. openGauss=# insert into join_2 values(1, 1), (2, 3), (4, 4);
  5. openGauss=# select join_1 join join_2;
  6. col1 | col2 | col1 | col2
  7. ------+------+------+------
  8. 1 | 2 | 1 | 1
  9. 1 | 2 | 2 | 3
  10. 1 | 2 | 4 | 4
  11. 3 | 3 | 1 | 1
  12. 3 | 3 | 2 | 3
  13. 3 | 3 | 4 | 4
  14. openGauss=# select join_1 inner join join_2;
  15. col1 | col2 | col1 | col2
  16. ------+------+------+------
  17. 1 | 2 | 1 | 1
  18. 1 | 2 | 2 | 3
  19. 1 | 2 | 4 | 4
  20. 3 | 3 | 1 | 1
  21. 3 | 3 | 2 | 3
  22. 3 | 3 | 4 | 4
  • SELECT 语句中使用FROM DUAL 示例
  1. openGauss=# select 1 as col;
  2. col
  3. -----
  4. 1
  5. (1 row)
  6. openGauss=# select 1 as col FROM DUAL;
  7. col
  8. -----
  9. 1
  10. (1 row)
  • SELECT FROM PARTITION子句指定多个分区
  1. openGauss=# create table multi_partition_select_test(C_INT INTEGER) partition by range(C_INT)
  2. openGauss-# (
  3. openGauss(# partition test_part1 values less than (400),
  4. openGauss(# partition test_part2 values less than (700),
  5. openGauss(# partition test_part3 values less than (1000)
  6. openGauss(# );
  7. CREATE TABLE
  8. openGauss=# insert into multi_partition_select_test values(111);
  9. INSERT 0 1
  10. openGauss=# insert into multi_partition_select_test values(555);
  11. INSERT 0 1
  12. openGauss=# insert into multi_partition_select_test values(888);
  13. INSERT 0 1
  14. openGauss=# select a.* from multi_partition_select_test partition (test_part1, test_part2) a;
  15. c_int
  16. -------
  17. 111
  18. 555
  19. (2 rows)
  • UNION子句非相似数据类型按 TEXT 类型进行转换示例:
  1. -- 首先创建兼容模式为B的数据库
  2. CREATE DATABASE mydb WITH DBCOMPATIBILITY 'B';
  3. \c mydb
  4. -- 创建两个表并插入测试数据
  5. CREATE TABLE tbl_date(col DATE);
  6. INSERT INTO tbl_date VALUES('2000-02-16');
  7. CREATE TABLE tbl_json(col JSON);
  8. INSERT INTO tbl_json VALUES('{"id":1,"dbname":"openGauss","language":"C++"}');
  9. -- UNION 查询,将会使用TEXT类型进行转换
  10. SELECT * FROM tbl_date UNION SELECT * FROM tbl_json;
  • 兼容MySQL兼容性全文索引语法查询,前提是兼容模式为B的数据库。
  1. openGauss=# CREATE SCHEMA fulltext_test;
  2. CREATE SCHEMA
  3. openGauss=# set current_schema to 'fulltext_test';
  4. SET
  5. openGauss=# CREATE TABLE test (
  6. openGauss(# id int unsigned auto_increment not null primary key,
  7. openGauss(# title varchar,
  8. openGauss(# boby text,
  9. openGauss(# name name,
  10. openGauss(# FULLTEXT (title, boby) WITH PARSER ngram
  11. openGauss(# );
  12. NOTICE: CREATE TABLE will create implicit sequence "test_id_seq" for serial column "test.id"
  13. NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "test_pkey" for table "test"
  14. CREATE TABLE
  15. openGauss=# \d test
  16. Table "fulltext_test.test"
  17. Column | Type | Modifiers
  18. --------+-------------------+-------------------------
  19. id | uint4 | not null AUTO_INCREMENT
  20. title | character varying |
  21. boby | text |
  22. name | name |
  23. Indexes:
  24. "test_pkey" PRIMARY KEY, btree (id) TABLESPACE pg_default
  25. "test_to_tsvector_to_tsvector1_idx" gin (to_tsvector('ngram'::regconfig, title::text), to_tsvector('ngram'::regconfig, boby)) TABLESPACE pg_default
  26. openGauss=# \d test_to_tsvector_to_tsvector1_idx
  27. Index "fulltext_test.test_to_tsvector_to_tsvector1_idx"
  28. Column | Type | Definition
  29. --------------+------+----------------------------------------------
  30. to_tsvector | text | to_tsvector('ngram'::regconfig, title::text)
  31. to_tsvector1 | text | to_tsvector('ngram'::regconfig, boby)
  32. gin, for table "fulltext_test.test"
  33. openGauss=# DROP INDEX test_to_tsvector_to_tsvector1_idx;
  34. DROP INDEX
  35. openGauss=# ALTER TABLE test ADD FULLTEXT INDEX test_index_1 (title, boby) WITH PARSER ngram;
  36. ALTER TABLE
  37. openGauss=# DROP INDEX test_index_1;
  38. DROP INDEX
  39. openGauss=# CREATE FULLTEXT INDEX test_index_1 ON test (title, boby) WITH PARSER ngram;
  40. CREATE INDEX
  41. openGauss=# \d test_index_1
  42. Index "fulltext_test.test_index_1"
  43. Column | Type | Definition
  44. --------------+------+----------------------------------------------
  45. to_tsvector | text | to_tsvector('ngram'::regconfig, title::text)
  46. to_tsvector1 | text | to_tsvector('ngram'::regconfig, boby)
  47. gin, for table "fulltext_test.test"
  48. openGauss=# INSERT INTO test(title, boby, name) VALUES('test', '&67575@gauss', 'opengauss');
  49. INSERT 0 1
  50. openGauss=# INSERT INTO test(title, boby, name) VALUES('test1', 'gauss', 'opengauss');
  51. INSERT 0 1
  52. openGauss=# INSERT INTO test(title, boby, name) VALUES('test2', 'gauss2', 'opengauss');
  53. INSERT 0 1
  54. openGauss=# INSERT INTO test(title, boby, name) VALUES('test3', 'test', 'opengauss');
  55. INSERT 0 1
  56. openGauss=# INSERT INTO test(title, boby, name) VALUES('gauss_123_@', 'test', 'opengauss');
  57. INSERT 0 1
  58. openGauss=# INSERT INTO test(title, boby, name) VALUES('', '', 'opengauss');
  59. INSERT 0 1
  60. openGauss=# INSERT INTO test(title, boby, name) VALUES(' ', ' ', ' ');
  61. INSERT 0 1
  62. openGauss=# SELECT * FROM TEST;
  63. id | title | boby | name
  64. ----+-------------+--------------+-----------
  65. 1 | test | &67575@gauss | opengauss
  66. 2 | test1 | gauss | opengauss
  67. 3 | test2 | gauss2 | opengauss
  68. 4 | test3 | test | opengauss
  69. 5 | gauss_123_@ | test | opengauss
  70. 6 | | | opengauss
  71. 7 | | |
  72. (7 rows)
  73. openGauss=# SELECT * FROM TEST WHERE MATCH (title, boby) AGAINST ('test');
  74. id | title | boby | name
  75. ----+-------------+--------------+-----------
  76. 1 | test | &67575@gauss | opengauss
  77. 2 | test1 | gauss | opengauss
  78. 3 | test2 | gauss2 | opengauss
  79. 4 | test3 | test | opengauss
  80. 5 | gauss_123_@ | test | opengauss
  81. (5 rows)
  82. openGauss=# SELECT * FROM TEST WHERE MATCH (title, boby) AGAINST ('gauss');
  83. id | title | boby | name
  84. ----+-------------+--------------+-----------
  85. 1 | test | &67575@gauss | opengauss
  86. 2 | test1 | gauss | opengauss
  87. 3 | test2 | gauss2 | opengauss
  88. 5 | gauss_123_@ | test | opengauss
  89. (4 rows)
  90. openGauss=# DROP INDEX test_index_1;
  91. DROP INDEX
  92. openGauss=# CREATE FULLTEXT INDEX test_index_1 ON test (boby) WITH PARSER ngram;
  93. CREATE INDEX
  94. openGauss=# \d test_index_1
  95. Index "fulltext_test.test_index_1"
  96. Column | Type | Definition
  97. -------------+------+---------------------------------------
  98. to_tsvector | text | to_tsvector('ngram'::regconfig, boby)
  99. gin, for table "fulltext_test.test"
  100. openGauss=# SELECT * FROM test WHERE MATCH (boby) AGAINST ('test');
  101. id | title | boby | name
  102. ----+-------------+------+-----------
  103. 4 | test3 | test | opengauss
  104. 5 | gauss_123_@ | test | opengauss
  105. (2 rows)
  106. openGauss=# SELECT * FROM test WHERE MATCH (boby) AGAINST ('gauss');
  107. id | title | boby | name
  108. ----+-------+--------------+-----------
  109. 1 | test | &67575@gauss | opengauss
  110. 2 | test1 | gauss | opengauss
  111. 3 | test2 | gauss2 | opengauss
  112. (3 rows)
  113. openGauss=# DROP INDEX test_index_1;
  114. DROP INDEX
  115. openGauss=# CREATE FULLTEXT INDEX test_index_1 ON test (title, boby, name) WITH PARSER ngram;
  116. CREATE INDEX
  117. openGauss=# \d test_index_1
  118. Index "fulltext_test.test_index_1"
  119. Column | Type | Definition
  120. --------------+------+----------------------------------------------
  121. to_tsvector | text | to_tsvector('ngram'::regconfig, title::text)
  122. to_tsvector1 | text | to_tsvector('ngram'::regconfig, boby)
  123. to_tsvector2 | text | to_tsvector('ngram'::regconfig, name::text)
  124. gin, for table "fulltext_test.test"
  125. openGauss=# SELECT * FROM test WHERE MATCH (title, boby, name) AGAINST ('test');
  126. id | title | boby | name
  127. ----+-------------+--------------+-----------
  128. 1 | test | &67575@gauss | opengauss
  129. 2 | test1 | gauss | opengauss
  130. 3 | test2 | gauss2 | opengauss
  131. 4 | test3 | test | opengauss
  132. 5 | gauss_123_@ | test | opengauss
  133. (5 rows)
  134. openGauss=# SELECT * FROM test WHERE MATCH (title, boby, name) AGAINST ('gauss');
  135. id | title | boby | name
  136. ----+-------------+--------------+-----------
  137. 1 | test | &67575@gauss | opengauss
  138. 2 | test1 | gauss | opengauss
  139. 3 | test2 | gauss2 | opengauss
  140. 4 | test3 | test | opengauss
  141. 5 | gauss_123_@ | test | opengauss
  142. 6 | | | opengauss
  143. (6 rows)
  144. openGauss=# SELECT * FROM test WHERE MATCH (title, boby, name) AGAINST ('opengauss');
  145. id | title | boby | name
  146. ----+-------------+--------------+-----------
  147. 1 | test | &67575@gauss | opengauss
  148. 2 | test1 | gauss | opengauss
  149. 3 | test2 | gauss2 | opengauss
  150. 4 | test3 | test | opengauss
  151. 5 | gauss_123_@ | test | opengauss
  152. 6 | | | opengauss
  153. (6 rows)
  154. openGauss=# drop table if exists articles;
  155. NOTICE: table "articles" does not exist, skipping
  156. DROP TABLE
  157. openGauss=# CREATE TABLE articles (
  158. openGauss(# ID int,
  159. openGauss(# title VARCHAR(100),
  160. openGauss(# FULLTEXT INDEX ngram_idx(title)WITH PARSER ngram
  161. openGauss(# );
  162. CREATE TABLE
  163. openGauss=# \d articles
  164. Table "fulltext_test.articles"
  165. Column | Type | Modifiers
  166. --------+------------------------+-----------
  167. ID | integer |
  168. title | character varying(100) |
  169. Indexes:
  170. "ngram_idx" gin (to_tsvector('ngram'::regconfig, title::text)) TABLESPACE pg_default
  171. openGauss=# drop table if exists articles;
  172. DROP TABLE
  173. openGauss=# CREATE TABLE articles (
  174. openGauss(# ID int,
  175. openGauss(# title VARCHAR(100),
  176. openGauss(# FULLTEXT INDEX (title)WITH PARSER ngram
  177. openGauss(# );
  178. CREATE TABLE
  179. openGauss=# \d articles
  180. Table "fulltext_test.articles"
  181. Column | Type | Modifiers
  182. --------+------------------------+-----------
  183. ID | integer |
  184. title | character varying(100) |
  185. Indexes:
  186. "articles_to_tsvector_idx" gin (to_tsvector('ngram'::regconfig, title::text)) TABLESPACE pg_default
  187. openGauss=# drop table if exists articles;
  188. DROP TABLE
  189. openGauss=# CREATE TABLE articles (
  190. openGauss(# ID int,
  191. openGauss(# title VARCHAR(100),
  192. openGauss(# FULLTEXT KEY keyngram_idx(title)WITH PARSER ngram
  193. openGauss(# );
  194. CREATE TABLE
  195. openGauss=# \d articles
  196. Table "fulltext_test.articles"
  197. Column | Type | Modifiers
  198. --------+------------------------+-----------
  199. ID | integer |
  200. title | character varying(100) |
  201. Indexes:
  202. "keyngram_idx" gin (to_tsvector('ngram'::regconfig, title::text)) TABLESPACE pg_default
  203. openGauss=# drop table if exists articles;
  204. DROP TABLE
  205. openGauss=# CREATE TABLE articles (
  206. openGauss(# ID int,
  207. openGauss(# title VARCHAR(100),
  208. openGauss(# FULLTEXT KEY (title)WITH PARSER ngram
  209. openGauss(# );
  210. CREATE TABLE
  211. openGauss=# \d articles
  212. Table "fulltext_test.articles"
  213. Column | Type | Modifiers
  214. --------+------------------------+-----------
  215. ID | integer |
  216. title | character varying(100) |
  217. Indexes:
  218. "articles_to_tsvector_idx" gin (to_tsvector('ngram'::regconfig, title::text)) TABLESPACE pg_default
  219. openGauss=# create table table_ddl_0154(col1 int,col2 varchar(64), FULLTEXT idx_ddl_0154(col2));
  220. CREATE TABLE
  221. openGauss=# create table table_ddl_0085(
  222. openGauss(# id int(11) not null,
  223. openGauss(# username varchar(50) default null,
  224. openGauss(# sex varchar(5) default null,
  225. openGauss(# address varchar(100) default null,
  226. openGauss(# score_num int(11));
  227. CREATE TABLE
  228. openGauss=# create fulltext index idx_ddl_0085_02 on table_ddl_0085(username);
  229. CREATE INDEX
  230. openGauss=# insert into table_ddl_0085 values (1,'test','m','xi''an changanqu', 10001), (2,'tst','w','xi''an beilingqu', 10002),
  231. (3,'es','w','xi''an yangtaqu', 10003),(4,'s','m','beijingchaoyangqu', 10004);
  232. INSERT 0 4
  233. openGauss=# SELECT * FROM table_ddl_0085 WHERE MATCH (username) AGAINST ('te' IN NATURAL LANGUAGE MODE);
  234. id | username | sex | address | score_num
  235. ----+----------+-----+-----------------+-----------
  236. 1 | test | m | xi'an changanqu | 10001
  237. (1 row)
  238. openGauss=# SELECT * FROM table_ddl_0085 WHERE MATCH (username) AGAINST ('ts' IN NATURAL LANGUAGE MODE WITH QUERY EXPANSION);
  239. id | username | sex | address | score_num
  240. ----+----------+-----+-----------------+-----------
  241. 2 | tst | w | xi'an beilingqu | 10002
  242. (1 row)
  243. openGauss=# SELECT * FROM table_ddl_0085 WHERE MATCH (username) AGAINST ('test' IN BOOLEAN MODE);
  244. id | username | sex | address | score_num
  245. ----+----------+-----+-----------------+-----------
  246. 1 | test | m | xi'an changanqu | 10001
  247. (1 row)
  248. openGauss=# SELECT * FROM table_ddl_0085 WHERE MATCH (username) AGAINST ('es' WITH QUERY EXPANSION);
  249. id | username | sex | address | score_num
  250. ----+----------+-----+-----------------+-----------
  251. 1 | test | m | xi'an changanqu | 10001
  252. 3 | es | w | xi'an yangtaqu | 10003
  253. (2 rows)
  254. openGauss=# SELECT * FROM table_ddl_0085 WHERE MATCH (username) AGAINST ('s');
  255. id | username | sex | address | score_num
  256. ----+----------+-----+-------------------+-----------
  257. 4 | s | m | beijingchaoyangqu | 10004
  258. (1 row)
  259. openGauss=# insert into table_ddl_0085 select * from table_ddl_0085 where match (username) against ('te' IN NATURAL LANGUAGE MODE);
  260. INSERT 0 1
  261. openGauss=# select * from table_ddl_0085;
  262. id | username | sex | address | score_num
  263. ----+----------+-----+-------------------+-----------
  264. 1 | test | m | xi'an changanqu | 10001
  265. 2 | tst | w | xi'an beilingqu | 10002
  266. 3 | es | w | xi'an yangtaqu | 10003
  267. 4 | s | m | beijingchaoyangqu | 10004
  268. 1 | test | m | xi'an changanqu | 10001
  269. (5 rows)
  270. openGauss=# create fulltext index idx_ddl_0085_03 on table_ddl_0085(username) with parser ngram visible;
  271. CREATE INDEX
  272. openGauss=# create fulltext index idx_ddl_0085_04 on table_ddl_0085(username) visible with parser ngram;
  273. CREATE INDEX
  274. openGauss=# create fulltext index idx_ddl_0085_05 on table_ddl_0085(username) visible;
  275. CREATE INDEX
  276. openGauss=# create fulltext index idx_ddl_0085_06 on table_ddl_0085(username) with parser ngram comment 'TEST FULLTEXT INDEX COMMENT';
  277. CREATE INDEX
  278. openGauss=# create fulltext index idx_ddl_0085_07 on table_ddl_0085(username) comment 'TEST FULLTEXT INDEX COMMENT' with parser ngram;
  279. CREATE INDEX
  280. openGauss=# create fulltext index idx_ddl_0085_08 on table_ddl_0085(username) comment 'TEST FULLTEXT INDEX COMMENT';
  281. CREATE INDEX
  282. openGauss=# drop schema fulltext_test cascade;
  283. NOTICE: drop cascades to 4 other objects
  284. DETAIL: drop cascades to table test
  285. drop cascades to table articles
  286. drop cascades to table table_ddl_0154
  287. drop cascades to table table_ddl_0085
  288. DROP SCHEMA
  289. openGauss=# reset current_schema;
  290. RESET

相关链接

SELECT