Oracle BLOB data type

前端之家收集整理的这篇文章主要介绍了Oracle BLOB data type前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

Define BLOB
sql> CREATE TABLE TESTTAB(A BLOB)


INSERT BLOB
sql> INSERT INTO TESTTAB VALUES(HEXTORAW('61626364'));
sql> INSERT INTO TESTTAB VALUES(UTL_RAW.CAST_TO_RAW('ABCD'));

sql> SELECT A FROM TESTTAB;
A
--------------------------------------------------------------------------------
61626364
41424344



Operate on BLOB

sql> SELECT DBMS_LOB.SUBSTR(A) FROM TESTTAB;
DBMS_LOB.SUBSTR(A)
--------------------------------------------------------------------------------
61626364
41424344

sql> SELECT DBMS_LOB.SUBSTR(A,DBMS_LOB.GETLENGTH(A) - 1) FROM TESTTAB;
DBMS_LOB.SUBSTR(A,DBMS_LOB.GETLENGTH(A)-1)
--------------------------------------------------------------------------------
616263
414243

sql> SELECT UTL_RAW.CAST_TO_VARCHAR2(DBMS_LOB.SUBSTR(A)) FROM TESTTAB;

UTL_RAW.CAST_TO_VARCHAR2(DBMS_LOB.SUBSTR(A))
--------------------------------------------------------------------------------
abcd
ABCD

猜你在找的Oracle相关文章