MySQL Workbench 将结果显示为 BLOB
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13634369/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
MySQL Workbench shows results as BLOB
提问by Mr. Boy
I keep finding that MySQL Workbench shows query results as BLOB
. e.g:
SELECT INET_NTOA(167773449)
--> BLOB
我一直发现 MySQL Workbench 将查询结果显示为BLOB
. 例如:
SELECT INET_NTOA(167773449)
-->BLOB
If I select to 'view value' I can determine the text value is '10.0.5.9' but it's pretty irritating when I SELECT multiple rows and want to glance at the contents.
如果我选择“查看值”,我可以确定文本值是“10.0.5.9”,但是当我选择多行并想看一眼内容时会很烦人。
Is there a way around this or is it a limitation of the tool?
有没有办法解决这个问题,还是工具的限制?
回答by Tariq
Background:This problem occurs when the binary string values (BINARY/VARBINARY type) are returned in the results. The binary strings contain the zero bytes and for some reason, apparently security, have not been shown by default. More details about binary strings here.
背景:当结果中返回二进制字符串值(BINARY/VARBINARY 类型)时,会出现此问题。二进制字符串包含零字节,出于某种原因,显然是安全的,默认情况下没有显示。关于二进制字符串的更多细节在这里。
Even in the reported example SELECT INET_NTOA(167773449)
, the function returns binary string. Check thisfor reference.
即使在报告的示例中SELECT INET_NTOA(167773449)
,该函数也返回二进制字符串。检查此以供参考。
Solution:Since MySQL Workbench v5.2.22, it can be set through preferences whether to SHOW or HIDE such values.
解决方案:从 MySQL Workbench v5.2.22 开始,可以通过首选项设置是否显示或隐藏此类值。
- In MySQL Workbench, go to: "Edit -> Preferences... -> SQL Queries"OR "Edit -> Preferences... -> SQL Editor -> SQL Execution"(depending upon what version of Workbench you have).
- Check the option 'Treat BINARY/VARBINARY as nonbinary character string' to show the actual value.
- 在 MySQL Workbench 中,转到:“编辑 -> 首选项... -> SQL 查询”或“编辑 -> 首选项... -> SQL 编辑器 -> SQL 执行”(取决于您拥有的 Workbench 版本)。
- 选中选项“将 BINARY/VARBINARY 视为非二进制字符串”以显示实际值。
Reference:The original issue has been reported and answered with fix here.
参考:原始问题已在此处报告并已修复。
回答by Sweet Chilly Philly
What you can do is Cast your BLOB type to a string. This will simply allow you to glance at whats in your BLOB type when browsing your select statement.
您可以做的是将您的 BLOB 类型转换为字符串。这只会让您在浏览 select 语句时浏览 BLOB 类型中的内容。
SELECT CAST(`blob_column_name` AS CHAR(10000) CHARACTER SET utf8) FROM `table_name`;