Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: No SQL - Unloader in Oracle 9i
Mark Townsend <markbtownsend_at_home.com> wrote in message news:<B7615758.2E2D%markbtownsend_at_home.com>...
> in article 20010629003225.02486.00001439_at_ng-mj1.aol.com, Uchakra at
> uchakra_at_aol.com wrote on 6/28/01 9:32 PM:
>
> > It will be helpful.
>
> Well - have a look at DBMS_METADATA in the docs - it won't unload the data,
> but it will give you the DDL. See
> http://download-west.oracle.com/otndoc/oracle9i/901_doc/appdev.901/a88894/ad
> x13met.htm
I for one, do not think XML is all that great of an idea. It reminds me of a long winded version of EDI.
Nevertheless back to the main point of this thread, better data unloading. Yes it would be nice if Oracle provided a data unloader utility, but you can use SQL to mimic some of its desired features such creating comma delimited output. I lost a better version but here is some SQL to generate a CSV file:
In sqlplus you just spool the resuts of the select to a file. You can use the following sqlplus commands to format the file for use:
set pagesize 0 <== eliminate headings, pagebreaks set linesize 133 <== adjust to write entire row to one line set feedback off <== eliminate number of rows processed msg set echo off <== eliminate sql from showing in result set set verify off <== eliminate substitution var from showing
To create a delimited file you just concatenate all the columns together something like col1||','||col2||',' etc....
You can generate the sql to create the delimited file with code like
this:
set pagesize 0
set feedback off
spool george3.sql
select column_name||'||'',''||'
from sys.dba_tab_columns
where table_name = 'ITEM_MASTER'
/
spool off
Which will give you a file that looks something like:
X,,,,,,,,,,,,,,,,,,,1,,,,,EZ SPEC LH ROT PORT PLEASUREMARINE,,,,N,N,,,80140 set echo off
'||'',''||'|| decode(data_type,'VARCHAR2','''"''||'||column_name||'||''"''', column_name))