且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在Oracle SQL中从BLOB获取文本内容

更新时间:2022-12-17 23:17:51

首先,您可能希望将文本存储在CLOB/NCLOB列中,而不是将BLOB用于二进制数据(您的查询将与CLOB一起使用) ,顺便说一句.)

First of all, you may want to store text in CLOB/NCLOB columns instead of BLOB, which is designed for binary data (your query would work with a CLOB, by the way).

以下查询将让您看到blob中文本的前32767个字符(最多),前提是所有字符集都兼容(存储在BLOB中的文本的原始CS,用于VARCHAR2的数据库的CS ):

The following query will let you see the first 32767 characters (at most) of the text inside the blob, provided all the character sets are compatible (original CS of the text stored in the BLOB, CS of the database used for VARCHAR2) :

select utl_raw.cast_to_varchar2(dbms_lob.substr(BLOB_FIELD)) from TABLE_WITH_BLOB where ID = '<row id>';