连接sys用户
sqlPLUS / AS SYSDBA
创建表
CREATE TABLE TEST01 (FNAME VARCHAR2(50),CONTENT BLOB);
创建图片所在目录
CREATE OR REPLACE DIRECTORY TEST_DIR AS 'C:\Pictures';
授权给SCOTT用户
GRANT READ,WRITE ON DIRECTORY TEST_DIR TO SCOTT;
连接SCOTT
CONN SCOTT/TIGER
插入图片(BLOB类型)
DECLARE 2 tempimg BLOB; 3 tempdir BFILE:=BFILENAME('TEST_DIR','green.jpg'); 4 BEGIN 5 INSERT INTO TEST01 VALUES ('green.jpg',EMPTY_BLOB()) RETURNING CONTENT INTO TEMPIMG; 6 DBMS_LOB.FILEOPEN(tempdir); 7 DBMS_LOB.LOADFROMFILE(tempimg,tempdir,DBMS_LOB.GETLENGTH(tempdir)); 8 DBMS_LOB.FILECLOSE(tempdir); 9 COMMIT; 10 END; 11 /原文链接:https://www.f2er.com/oracle/211142.html