微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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.

原文地址:https://www.jb51.cc/mssql/80491.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐