Oracle LOB 总结

来源:互联网 发布:国学大师软件下载 编辑:程序博客网 时间:2024/06/14 17:13

1. BLOB

CREATE TABLE SCOTT.MYBLOB(ID varchar2(50),DATA BLOB);
CREATE OR REPLACE DIRECTORY LOBFILEDIR AS 'F:/LOBDIR';

[a] PL/SQL插入BLOB

DECLARE
   a_blob  BLOB;
   a_bfile BFILE := BFILENAME('LOBFILEDIR','Winter.jpg'); --用来指向外部操作系统
BEGIN  
   INSERT INTO SCOTT.MYBLOB(ID,DATA) VALUES ('20000',EMPTY_BLOB()) returning DATA INTO a_blob;

   dbms_lob.fileopen(a_bfile);
   dbms_lob.loadfromfile(a_blob, a_bfile, dbms_lob.getlength(a_bfile));
   dbms_lob.fileclose(a_bfile);
   commit;
end; 

/

[b] SQL插入BLOB

insert into scott.myblob(ID,DATA) values('10000',EMPTY_BLOB());

insert into scott.myblob(ID,DATA) values('30000','101010101101010101101010');

commit;

CLOB是跟BLOB同样操作.

 

原创粉丝点击