加入收藏 | 设为首页 | 会员中心 | 我要投稿 拼字网 - 核心网 (https://www.hexinwang.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > MsSql教程 > 正文

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

发布时间:2020-12-24 18:12:01 所属栏目:MsSql教程 来源:网络整理
导读:我安装了pg_trgm模块. pg_trgm | 1.0 | extensions | text similarity measurement and index ... 架构集是扩展.要使用它,我必须运行类似这样的选择: extensions.similarity('hello','hallo'); 我正在尝试使用%运算符运行语句并获得以下消息. mydb=# select

我安装了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.

(编辑:拼字网 - 核心网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    热点阅读