Heim >Datenbank >MySQL-Tutorial >Oracle超大数据导出为文本文件

Oracle超大数据导出为文本文件

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-07 17:09:261261Durchsuche

要从Oracle导出部分数据到文本文件中(flatfile),由于数据表很大,使用toad时导出失败,居然说内存溢出。看来还是用Oracle自己的命

要从Oracle导出部分数据到文本文件中(flatfile),由于数据表很大,使用toad时导出失败,,居然说内存溢出。看来还是用Oracle自己的命令来完成吧。

首先需要准备导出的目录,假设为 /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;

即便是导出上G的数据,也会非常的快。
试试吧。 

linux

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn