简体   繁体   English

将BLOB转换为sql中的文本

[英]convert BLOB to text in sql

I have a field in my database table with data type as BLOB .How can I view the content as text/string using a SELECT query in SQL . 我的数据库表中有一个字段,数据类型为BLOB如何使用SQLSELECT查询将内容视为text/string the content's MIMETYPE is 'text/xml charset=UTF8' 内容的MIMETYPE'text/xml charset=UTF8'

I tried with this, I'm not sure if im right with the syntax 我试过这个,我不确定我是否正确的语法

SELECT 
CAST((SELECT column FROM myTable WHERE ID='56')AS CHAR(10000) CHARACTER SET utf8)

and also 并且

SELECT 
CONVERT(VARCHAR(max), CAST((SELECT column FROM myTable WHERE ID='56') 
as binary)) from BIZDOCCONTENT

many Thanks 非常感谢

Try: 尝试:

SELECT CONVERT(object USING utf8)
FROM tablename

试试这个查询 -

SELECT CONVERT(column USING utf8) FROM myTable WHERE ID=56

I had the same problem - I just changed the field type in phpmyadmin! 我遇到了同样的问题 - 我刚刚更改了phpmyadmin中的字段类型! And what i see : 而我所看到的:

ALTER TABLE pages CHANGE content content TEXT NULL DEFAULT NULL ALTER TABLE pages CHANGE content content TEXT NULL DEFAULT NULL
('content' - my field which was in BLOB-type) ('内容' - 我的字段是BLOB类型)

CREATE OR REPLACE FUNCTION HASTANE.getXXXXX(p_rowid in rowid) RETURN VARCHAR2
AS
    l_data long;
BEGIN
    SELECT XXXXXX INTO l_data FROM XXXXX WHERE rowid = p_rowid;
    RETURN substr(l_data, 1, 4000);
END getXXXXXX;

Set your content type in php: 在php中设置您的内容类型:

header("Content-type: image/jpg"); //Send the content Type here.
print $data['blob_data'];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM