SQL> create directory unload_dir as
'd:\oracle_unload';
Directory created
SQL> grant read,write on directory unload_dir to
shuju;
Grant succeeded
向文件输出数据测试:
declare
handle utl_file.file_type;
buf varchar2(2000);
begin
handle
:=utl_file.fopen('UNLOAD_DIR','xiaopeng.txt','w',10000);
for i in 1..10000 loop
buf :=to_char(i)||'测试输出效果。';
utl_file.put(handle,buf);
utl_file.new_line(handle);
end loop;
utl_file.fclose(handle);
end;
/
执行时间0.125秒,远远低于显示时间。
Executed in 0.125 seconds
读数据库,将结果写到文件中,结果集39040条记录
declare
handle utl_file.file_type;
buf varchar2(2000);
i number(6) :=1;
cursor c_a1
is select * from AJLJ071
<