Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Opposite of SQL*Loader
Here is a script that can give you the ASCII dump.
As you can see, I did not write it. Jared Still wrote it.
Its beautiful !!!
Oracleguru
www.oracleguru.net
oracleguru_at_mailcity.com
set trimspool on
set serverout on
clear buffer
undef dumpfile
undef dumptable
undef dumpowner
var maxcol number
var linelen number
var dumpfile char(40)
col column_id noprint
set pages0 feed off termout on echo off verify off
accept dumpowner char prompt 'Owner of table to dump: '
accept dumptable char prompt 'Table to dump: '
begin
select max(column_id) into :maxcol from all_tab_columns where table_name = rtrim(upper('&dumptable')) and owner = rtrim(upper('&dumpowner')); select sum(data_length) + ( :maxcol * 3 ) into :linelen from all_tab_columns where table_name = rtrim(upper('&dumptable')) and owner = rtrim(upper('&dumpowner'));end;
select 'set trimspool on' from dual; select 'set termout off pages 0 heading off echo off' from dual; select 'set line ' || :linelen from dual; select 'spool ' || lower('&dumptable') || '.txt' from dual; select 'select' || chr(10) from dual; select ' ' || '''' || '"' || '''' || ' || ' || 'replace(' || column_name || ',' || '''' || '"' || '''' || ') ' || ' ||' || '''' || '",' || '''' || ' || ', column_id
'replace(' || column_name || ',' || '''' || '"' || '''' || ') ' || ' ||' || '''' || '"' || '''', column_id
select 'from &dumpowner..&dumptable' from dual; select '/' from dual; select 'spool off' from dual;
select 'userid = /' || chr(10) ||
'control = ' || lower('&dumptable') || '.ctl' || chr(10) || 'log = ' || lower('&dumptable') || '.log' || chr(10) || 'bad = ' || lower('&dumptable')|| '.bad' || chr(10)from dual;
'infile ' || ''''|| lower('&dumptable') || '.txt' || '''' || chr(10) ||
'into table &dumptable' || chr(10) || 'fields terminated by ' || '''' || ',' || '''' || 'optionally enclosed by ' || '''' || '"' || '''' || chr(10)from dual;
column_id
from all_tab_columns
where table_name = upper('&dumptable')
and owner = upper('&dumpowner')
and column_id < :maxcol
union
select ' ' || column_name, column_id
from all_tab_columns
where table_name = upper('&dumptable')
and owner = upper('&dumpowner')
and column_id = :maxcol
order by 2
/
select ')' from dual;
exit
Andrew D. Arenson <arenson_at_swan.imgen.bcm.tmc.edu> wrote in article <wqemuor4ot.fsf_at_swan.imgen.bcm.tmc.edu>...
> > I am familiar with the Sybase utility bcp (bulk copy) which can > be used to copy tab-delimited files of data into or out of a Sybase > table. > > I would like to do the same thing in Oracle. From what I've read, > SQL*Loader will achieve this handily and with _much_ more flexibility > when I want to load data INTO an Oracle table. > > What do I use to bulk copy data OUT OF an Oracle table? > > I understand that I could write a fairly simple piece of code to do > this, but I find it hard to believe that there isn't a utility like > SQL*Loader for drawing data out of an Oracle table. > > Andy > > > > -- > Andrew D. Arenson | http://gc.bcm.tmc.edu:8088/cgi-bin/andy/andy > Baylor College of Medicine | arenson_at_bcm.tmc.edu (713) H 520-7392 > Genome Sequencing Center, Molecular & Human Genetics Dept. | W 798-4689 > One Baylor Plaza, Room S903, Houston, TX 77030 | F798-5386
![]() |
![]() |