postgresql pgAdmin III:如何查看 blob?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14875748/
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
pgAdmin III: How to view a blob?
提问by Haroldo_OK
I understand that PostgreSQL writes BLOB content to a separate table, but is there any way to view the blob contents in an easy and convenient way from inside pgAdmin?
我知道 PostgreSQL 将 BLOB 内容写入单独的表,但是有没有办法从 pgAdmin 内部以简单方便的方式查看 Blob 内容?
采纳答案by Chris Travers
I am not sure what you mean by "easy and convenient" but the best you can do is lo_read(...)
我不确定你所说的“简单方便”是什么意思,但你能做的最好的是 lo_read(...)
This presents the lob
as a bytea
.
这将lob
作为bytea
.
This is easy and convenient in the sense of getting data out but you pgAdmin won't convert from an escaped string back into the original binary for you so you are left looking at the textual representation of the binary, so it is not "easy and convenient" if you want to show the image contained in a lob when that is in png format or anything.
从获取数据的意义上来说,这很容易也很方便,但是您 pgAdmin 不会为您从转义字符串转换回原始二进制文件,因此您只能查看二进制文件的文本表示,因此它不是“容易和方便”,如果您想以 png 格式或任何格式显示 lob 中包含的图像。
回答by Stupidfrog
SELECT encode(blobdata::bytea, 'escape') FROM table as o where o.blobdata != ''
where
在哪里
- blobdata is the bytea column (blob)
- "table" is the table that contains the column blobdata
- blobdata 是 bytea 列 (blob)
- “表”是包含列 blobdata 的表