monetdb 正则表达式 select
monetdb regexp select
我正在使用 MonetDB 进行一些测试。
我正在尝试执行的查询的要点(使用借用的语法)是这样的:
SELECT mystring FROM mytable WHERE mystring REGEXP 'myxpression';
MonetDB 不支持这种语法,但文档声称它支持 PCRE,所以这 可能 是可能的,但语法仍然让我望而却步。
勾选 Does MonetDB support regular expression predicates?
The implementation is there in the MonetDB backend, the module that
implements it is pcre (to be found in MonetDB5 source tree).
I'm not sure whether it is available by default from MonetDB/SQL.
If not, with these two function definition, you link SQL functions to the
respective implementations in MonetDB5:
-- case sensitive
create function pcre_match(s string, pattern string)
returns BOOLEAN
external name pcre.match;
-- case insensitive
create function pcre_imatch(s string, pattern string)
returns BOOLEAN
external name pcre.imatch;
If you need more, I'd suggest to have a look at MonetDB5/src/modules/mal/
pcre.mx in the source code.
Use select name from sys.functions;
to check if the function exists, otherwise you will need to create it.
例如,您可以这样使用 pcre_imatch()
:
SELECT mystring FROM mytable WHERE pcre_imatch(mystring, 'myexpression');
我正在使用 MonetDB 进行一些测试。
我正在尝试执行的查询的要点(使用借用的语法)是这样的:
SELECT mystring FROM mytable WHERE mystring REGEXP 'myxpression';
MonetDB 不支持这种语法,但文档声称它支持 PCRE,所以这 可能 是可能的,但语法仍然让我望而却步。
勾选 Does MonetDB support regular expression predicates?
The implementation is there in the MonetDB backend, the module that implements it is pcre (to be found in MonetDB5 source tree). I'm not sure whether it is available by default from MonetDB/SQL.
If not, with these two function definition, you link SQL functions to the respective implementations in MonetDB5:
-- case sensitive create function pcre_match(s string, pattern string) returns BOOLEAN external name pcre.match;
-- case insensitive create function pcre_imatch(s string, pattern string) returns BOOLEAN external name pcre.imatch;
If you need more, I'd suggest to have a look at MonetDB5/src/modules/mal/ pcre.mx in the source code.
Use
select name from sys.functions;
to check if the function exists, otherwise you will need to create it.
例如,您可以这样使用 pcre_imatch()
:
SELECT mystring FROM mytable WHERE pcre_imatch(mystring, 'myexpression');