简体   繁体   中英

How to query BLOB as CLOB in H2 database

To project BLOB into CLOB in Oracle I can do this query:

SELECT ent.ID, to_clob(ent.blob_string) from entity_1 ent;

However, I could not find the to_clob equivalent operation in H2 to see my data in H2-console. How I can do that?

It depends on content of your BLOB. In H2 Console you actually can see BLOB and other binary values as is in hexadecimal representation without any additional functions around them.

You can use CAST(ent.blob_string AS VARCHAR) (or CAST(ent.blob_string AS CLOB) ) to convert a binary string to a character string explicitly, but such conversion uses different encodings in different versions of H2. Old versions use hexadecimal representation, new versions use UTF-8. You can use UTF8TOSTRING(ent.blob_string) function for UTF-8 conversion in old and new versions. There is also RAWTOHEX(ent.blob_string) function, but its behavior is also different between different versions of H2 and its compatibility modes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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