Create directory讓我們可以在Oracle數據庫中靈活的對文件進行讀寫操作
其語法為:
create or replace directory exp_dir as
目錄創建以後
grant read
此時用戶eygle就擁有了對該目錄的讀寫權限
讓我們看一個簡單的測試:
SQL> create or replace directory UTL_FILE_DIR as
Directory created
SQL> declare
PL/SQL procedure successfully completed
SQL> !
[oracle@jumper
eygle test write one
eygle test write two
[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_file
SYS BDUMP_DIR /opt/oracle/admin/conner/bdump
SYS 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_file
SYS BDUMP_DIR /opt/oracle/admin/conner/bdump
From:http://tw.wingwit.com/Article/program/Oracle/201311/17844.html