Informix SQL 文本 Blob 通配符搜索

发布于 2024-08-11 03:42:03 字数 221 浏览 1 评论 0原文

我正在寻找一种在文本(blob)列上使用通配符搜索的有效方法。
我已经看到它在内部存储为字节...... 数据量将受到限制,但不幸的是我的供应商决定使用这种愚蠢的数据类型。如果有一个简单的系统端函数可以修改它,我也会考虑移动临时表中的所有内容 - 不幸的是像 rpad 这样的东西不起作用......
通过使用选择部分中的列或通过 Perl 的 DBI 模块读取数据时,我可以正确地看到文本值。

I am looking for an efficient way to use a wild card search on a text (blob) column.
I have seen that it is internally stored as bytes...
The data amount will be limited, but unfortunately my vendor has decided to use this stupid datatype. I would also consider to move everything in a temp table if there is an easy system side function to modify it - unfortunately something like rpad does not work...
I can see the text value correctly via using the column in the select part or when reading the data via Perl's DBI module.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

池木 2024-08-18 03:42:03

不幸的是,您陷入了困境 - 您可以对 TEXT 或 BYTE blob 执行的操作非常少。特别是,这些都不起作用:

+ create table t (t text in table);
+ select t from t where t[1,3] = "abc";
SQL -615: Blobs are not allowed in this expression.
+ select t from t where t like "%abc%";
SQL -219: Wildcard matching may not be used with non-character types.
+ select t from t where t matches "*abc*";
SQL -219: Wildcard matching may not be used with non-character types.

根据 IDS 的版本,您可能可以选择 BTS - 基本文本搜索(需要 IDS v11)或其他文本搜索数据刀片。另一方面,如果数据已经在数据库中并且无法进行类型转换,那么您可能被迫提取 blob 并在客户端搜索它们,这效率较低。如果必须这样做,请确保过滤尽可能多的其他条件,以最大程度地减少所需的流量。

您可能还注意到,DBD::Informix 必须经历一些阴谋才能使 blob 看起来能够工作——坦率地说,它不应该经历这些阴谋。到目前为止,在十年的尝试中,我还没有说服人们这些事情需要解决。

Unfortunately, you are stuck - there are very few operations that you can perform on TEXT or BYTE blobs. In particular, none of these work:

+ create table t (t text in table);
+ select t from t where t[1,3] = "abc";
SQL -615: Blobs are not allowed in this expression.
+ select t from t where t like "%abc%";
SQL -219: Wildcard matching may not be used with non-character types.
+ select t from t where t matches "*abc*";
SQL -219: Wildcard matching may not be used with non-character types.

Depending on the version of IDS, you may have options with BTS - Basic Text Search (requires IDS v11), or with other text search data blades. On the other hand, if the data is already in the DB and cannot be type-converted, then you may be forced to extract the blobs and search them client-side, which is less efficient. If you must do that, ensure you filter on as many other conditions as possible to minimize the traffic that is needed.

You might also notice that DBD::Informix has to go through some machinations to make blobs appear to work - machinations that it should not, quite frankly, have to go through. So far, in a decade of trying, I've not persuaded people that these things need fixing.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文