创建目录
create or replace directory exp_dir as '/tmp';
赋权
grant read, write on directory exp_dir to PUBLIC; 测试写文件
declare
fhandle utl_file.file_type;
begin
fhandle := utl_file.fopen('exp_dir', 'example.txt', 'w');
utl_file.put_line(fhandle , 'eygle test write one');
utl_file.put_line(fhandle , 'eygle test write two');
utl_file.fclose(fhandle);
end;
/
测试读取文件
declare
fhandle utl_file.file_type;
fp_buffer varchar2(4000);
begin
fhandle := utl_file.fopen ('exp_dir','example.txt', 'R'); utl_file.get_line (fhandle , fp_buffer );
dbms_output.put_line(fp_buffer );
utl_file.get_line (fhandle , fp_buffer );
dbms_output.put_line(fp_buffer );
utl_file.fclose(fhandle);
end;
/ 可以查询dba_directories查看所有directory.
SQL> select * from dba_directories; 可以使用drop directory删除这些路径.
SQL> drop directory exp_dir;
04-13 15:48