Home >Database >Mysql Tutorial >How to Extract Text from a BLOB in Oracle SQL?
Extracting Textual Contents from BLOB in Oracle SQL
In Oracle SQL, LOB (Large Object) types, such as BLOB, are used to store binary data. To access the textual contents of a BLOB, you can use the following query:
select utl_raw.cast_to_varchar2(dbms_lob.substr(BLOB_FIELD)) from TABLE_WITH_BLOB where ID = '<row id>';
Explanation:
Example:
Assuming you have a table named MY_TABLE with a BLOB column named TEXT_FIELD that contains a text document, the following query will extract and display the first 32767 characters of the text:
select utl_raw.cast_to_varchar2(dbms_lob.substr(TEXT_FIELD)) from MY_TABLE where ID = 1;
The above is the detailed content of How to Extract Text from a BLOB in Oracle SQL?. For more information, please follow other related articles on the PHP Chinese website!