Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: newbie dumping tables and columns to text file
On Feb 9, 1:39 pm, seannakas..._at_yahoo.com wrote:
> Hello, I'm a newbie to sql and oracle. I'm using sqlplus on windows
> (probably doesn't matter what platform) and want to dump out all the
> user tables and columns to a text file. I would like the format to be
> as follows:
>
> MyTable1 > MyColumn1
> MyTable1 > MyColumn2
> ...
> MyTable2 > MyColumn1
> MyTable2 > MyColumn2
> ...
>
> Is there an sql script that can do this?
>
> thanks,
> Sean.
(1) create an script (say script_test.sql on D:\ ) as
set heading off
set feedback off
set echo off
spool d:\table.sql
SELECT TABLE_NAME||' > '||COLUMN_NAME FROM USER_TAB_COLUMNS
ORDER BY TABLE_NAME, COLUMN_NAME;
spool off;
(2) run the script on sql*plus as @d:\script_test.sql
This will create a output file on D:\ named as table.sql with the desired output. Received on Fri Feb 09 2007 - 05:10:35 CST