首页 > 数据库 > Oracle > oracle导出数据到txt文件
首先需要准备导出的目录,假设为 /opt/tmp,该目录需要Oracle的帐户可以读写。
create or replace directory utlexportpath as '/opt/tmp';
然后在sqlplus中即可使用如下方式把文件导出:
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;
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/25903968/viewspace-1675475/ ,如需转载,请注明出处,否则将追究法律责任。