sql – 如何使用扩展名pg_trgm中的%运算符?

我安装了pg_trgm模块.
pg_trgm | 1.0     | extensions | text similarity measurement and index ...

架构集是扩展.要使用它,我必须运行类似这样的选择:

extensions.similarity('hello','hallo');

我正在尝试使用%运算符运行语句并获得以下消息.

mydb=# select * from RSSdata where description % 'Brazil';
ERROR:  operator does not exist: character varying % unkNown
LINE 1: select * from RSSdata where description % 'Brazil';
                                            ^
HINT:  No operator matches the given name and argument type(s).
You might need to add explicit type casts.

运行%或< - >所需的内容操作符?

解决方法

最有可能这是 search_path一个问题.运行:
SHOW search_path;

包含pg_trgm的架构是否包括在内?如果没有,请加入.

或者,您可以对函数进行模式限定 – 甚至使用OPERATOR() construct的运算符:

SELECT * FROM RSSdata WHERE extensions.similarity(description,'Brazil') > .8;
SELECT * FROM RSSdata WHERE description OPERATOR(extensions.%) 'Brazil';

使其独立于search_path.

相关文章

SELECT a.*,b.dp_name,c.pa_name,fm_name=(CASE WHEN a.fm_n...
if not exists(select name from syscolumns where name=&am...
select a.*,pano=a.pa_no,b.pa_name,f.dp_name,e.fw_state_n...
要在 SQL Server 2019 中设置定时自动重启,可以使用 Window...
您收到的错误消息表明数据库 &#39;EastRiver&#39; 的...
首先我需要查询出需要使用SQL Server Profiler跟踪的数据库标...