我建了一个表tipian
create table tipian
(name char,
tupian blob)
tablespace myg;我如何插入一个图片
图片的位置在本机上目录为:f:\tupian\wangye\0079_gif.gif
我打算使用BFILENAME来指向目录和文件(需要有 DBA角色或 CREATE DIRECTORY 权限)。为了创建一个目录,要使用Create directory命令。如:
我执行下面的命令过不去
SQL> create directory '0079' for 'f:\tupian\wangye\';
create directory '0079' for 'f:\tupian\wangye\'
*
ERROR 位于第1行:
ORA-22929: 无效或遗失的目录名称请问如何把图片插入到表中?
create table tipian
(name char,
tupian blob)
tablespace myg;我如何插入一个图片
图片的位置在本机上目录为:f:\tupian\wangye\0079_gif.gif
我打算使用BFILENAME来指向目录和文件(需要有 DBA角色或 CREATE DIRECTORY 权限)。为了创建一个目录,要使用Create directory命令。如:
我执行下面的命令过不去
SQL> create directory '0079' for 'f:\tupian\wangye\';
create directory '0079' for 'f:\tupian\wangye\'
*
ERROR 位于第1行:
ORA-22929: 无效或遗失的目录名称请问如何把图片插入到表中?
grant create any library to scott;
create or replace directory utllobdir as 'G:\oracle';
create table bfile_tab (bfile_column BFILE);
create table utl_lob_test (blob_column BLOB);set serveroutput on然后执行下面语句就将G:\oracle目录下的Azul.jpg存入到utl_lob_test
表中的blob_column字段中了。
declare
a_blob BLOB;
a_bfile BFILE := BFILENAME('UTLLOBDIR','Azul.jpg');
begin
insert into bfile_tab values (a_bfile)
returning bfile_column into a_bfile;
insert into utl_lob_test values (empty_blob())
returning blob_column 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;
/
select dbms_lob.getlength(blob_column) from UTL_LOB_TEST;