PLSQL NOTE--------utl_file 的使用

utl_file

给用户文件操作权限

 -----rlwrap sqlplus sys/111111@localhost:1522/xe as sysdba
 -----以sysdba 身份登陆
  CREATE OR REPLACE DIRECTORY test_dir as '/sandbox/plsql_test';
  -----创建文件夹
  -----the /sandbox/plsql_test need command $chmod 777 /sandbox/plsql_test
  -----给写入权限(linux 系统)
  grant read,write on directory test_dir to &username;
  GRANT EXECUTE ON utl_file TO &username; 
  ---给oracle 用户文件操作权限
 select * from ALL_DIRECTORIES;
 ----查看oralce所有文件夹
 
 ------测试----------
 declare
     f utl_file.file_type;
 begin
     f := utl_file.fopen( 'TEST_DIR', 'testfile.txt', 'w'); -- w is the write mode
   utl_file.put_line(f, 'hello world');
   utl_file.put(f, ' ! ' );
   utl_file.fclose(f);
 end;
 /
 show errors;

你可能感兴趣的:(PLSQL NOTE--------utl_file 的使用)