Create directory讓我們可以在Oracle數據庫中靈活的對文件進行讀寫操作
其語法為:
CREATE [OR REPLACE] DIRECTORY directory AS
本案例具體創建如下:
create or replace directory exp_dir as
目錄創建以後
GRANT READ[
例如:
grant read
此時用戶eygle就擁有了對該目錄的讀寫權限
讓我們看一個簡單的測試:
SQL> create or replace directory UTL_FILE_DIR as
SQL> declare
PL/SQL procedure successfully completed
SQL> !
[oracle@jumper
類似的我們可以通過utl_file來讀取文件:
SQL> declare
eygle test write one
eygle test write two
PL/SQL procedure successfully completed
可以查詢dba_directories查看所有directory
SQL> select * from dba_directories;
OWNER DIRECTORY_NAME DIRECTORY_PATH
SYS UTL_FILE_DIR /opt/oracle/utl_fileSYS
BDUMP_DIR /opt/oracle/admin/conner/bdumpSYS EXP_DIR /opt/oracle/utl_file
可以使用drop directory刪除這些路徑
SQL> drop directory exp_dir;
Directory dropped
SQL> select * from dba_directories;
OWNER DIRECTORY_NAME DIRECTORY_PATH
SYS UTL_FILE_DIR /opt/oracle/utl_fileSYS
BDUMP_DIR /opt/oracle/admin/conner/bdump
create or replace directory USER_DIR as
DECLARE
v_content VARCHAR
v_bfile BFILE;
amount INT;
offset INT :=
BEGIN
v_bfile := bfilename(
amount :=DBMS_LOB
DBMS_LOB
DBMS_LOB
DBMS_LOB
DBMS_OUTPUT
END;
From:http://tw.wingwit.com/Article/program/Oracle/201311/17151.html