首先需要准备导出的目录,假设为 /opt/tmp,该目录需要Oracle的帐户可以读写。
create or replace directory utlexportpath as '/opt/tmp';
declare
outfile utl_file.file_type;
begin
outfile := utl_file.fopen('UTLEXPORTPATH','exp.txt','W');
for rec in (select col1,col2 from sometable where your conditions)
loop
utl_file.put_line(outfile, rec.col1||','||rec.col2);
end loop;
utl_file.fclose(f);
end;
即便是导出上G的数据,也会非常的快。
试试吧。