Home > Database > Mysql Tutorial > Oracle超大数据导出为文本文件

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

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 17:09:26
Original
1233 people have browsed it

要从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

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template