如何运行查询以在Blob文件中查找字符串? [英] How to run a query to find a string in blob files?
问题描述
Mediawiki在数据库文本"中有一个包含页面内容的表.它被保存为[BLOB]文件. 我想运行一个查询来搜索网站上的所有文本,以查看哪些页面包含特定的字符串". 如何运行查询来搜索[blob]文件?
Mediawiki has a table in the database 'text' which contains the page content. It is saved as a [BLOB] file. I would like to run a query to search through all the text on the site to see which pages contain a certain 'string'. How do I run a query to search [blob] files?
推荐答案
MediaWiki标记文本存储在old_text
字段中,该字段是 mediumblob 类型.您可以像其他任何基于文本的字段一样查询它. MySQL会将您的字符串转换为二进制以进行查询.请注意,这是区分大小写的搜索!
The Mediawiki markup text is stored in the old_text
field, which is a mediumblob type. You can query it like any other text-based field. MySQL will cast your string into binary for the query. Note that this is a case-sensitive search!
select old_id from text where old_text like "%string%";
如果需要区分大小写,则需要应用适当的字符集,该列的大小写不区分大小写:
If you need case-insensitivity then you need to apply an appropriate character set with a case-insensitive collation to the column:
SELECT old_id from text where CONVERT(old_text USING latin1) like '%STRing%';
请注意,如果您的表不小,这些查询将花费很长时间.
Be aware that if your table isn't small these queries will take a long time.
这篇关于如何运行查询以在Blob文件中查找字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!