Re: Export table to comma delimited file?
Date: 1995/09/09
Message-ID: <DEMstC.7BE_at_news.metropolis.nl>#1/1
dwest_at_ad3100.ada.epa.gov (Dan West) wrote:
>Is there a simple way to export an Oracle 7 table to a comma delimited
>ASCII file? I need to transport data from Oracle on a UNIX system to
>FoxPro on a PC. SQL*Loader allows me to import data in this format but
>I can't seem to find a way to export in this format short of having to
>specify every field and use concat with a select statement or writing
>an embedded SQL C program.
[all the obvious SET commands]
-- start with spool command
spool prep_export.sql
select 'spool export.asc'
from dual;
-- select the start of the statement
select 'select '||column_name
from user_tab_columns
where table_name = 'table'
and rownum < 2;
-- select the middle of the statement
select '||','||' decode(rownum,1,null,
column_name) <- you have to figure the quote business out yourself. I'm writing this out of memory.from user_tab_columns
where table_name = 'table';
-- knit a nice ending to it
select ' from table_name;'
from dual;
select 'spool off'
from dual;
spool off
the resulting file should be something like:
spool export.asc
select COLUMN1
||','||COLUMN2
||','||COLUMN3
from table_name;
spool off