什么是高级?这就叫高级—openGauss(352)

10 阅读1分钟

#openGauss #入门 #安装 #数据库 #开源

知识来源:docs-opengauss.osinfra.cn/zh/

例如:举一个现实生活中天文学上的例子。我们将使用表驱动的重写规则扩大supernovae的查询范围:

```
openGauss=# CREATE TABLE tsearch.aliases (id int, t tsquery, s tsquery);

openGauss=# INSERT INTO tsearch.aliases VALUES(1, to_tsquery('supernovae'), to_tsquery('supernovae|sn'));

openGauss=# SELECT ts_rewrite(to_tsquery('supernovae & crab'), 'SELECT t, s FROM tsearch.aliases');

           ts_rewrite            
---------------------------------
 'crab' & ( 'supernova' | 'sn' )


    
可以通过更新表修改重写规则:
    
    ```
    openGauss=# UPDATE tsearch.aliases
    SET s = to_tsquery('supernovae|sn & !nebulae')
    WHERE t = to_tsquery('supernovae');
    
    openGauss=# SELECT ts_rewrite(to_tsquery('supernovae & crab'), 'SELECT t, s FROM tsearch.aliases');
    
                     ts_rewrite                  
    ---------------------------------------------
     'crab' & ( 'supernova' | 'sn' & !'nebula' )

#openGauss #入门 #安装 #数据库 #开源

知识来源:docs-opengauss.osinfra.cn/zh/