Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: SQLPLUS: creating a text file with column header and tabel rows?

Re: SQLPLUS: creating a text file with column header and tabel rows?

From: Jim Smith <jim_at_jimsmith.demon.co.uk>
Date: Tue, 9 Aug 2005 16:39:27 +0100
Message-ID: <v+WvZQHv4M+CFwEB@jimsmith.demon.co.uk>


In message <1123598697.730400.167020_at_f14g2000cwb.googlegroups.com>, Caja <carsten.jacobs_at_web.de> writes
>Hello,
>
>I'm going crazy trying to create a simple thing.
>What I want is a textfile with the column names of a specific table in
>the first row and the content of the table in the other rows.
>
>The methods I already tried are something like
>
>spool table_content.txt
>set colsep |
>set headsep |
>set wrap on
>set pagesize 80000
>set trims on
>set feedback off
>set underline off
>select * from mytable;
>exit
>
>I can get either a file where the headline (column names) is multible
>in the file or not at all. I couldn't get just once in the first row.
try "set pagesize 0" to get rid of repeated headers.

>Furthermore has the output linefeeds in between 1 table row. But I want
>one table row in one file row.

Not sure what you mean here, but it may be that your line isn't wide enough.

Use set linesize n (I think there is a maximum width, depending on sqlplus version)
>
>Finally it should be a file which is separated by a delimiter and can
>be imported into a spreadsheet. It should also be table independent
>because the queried table could be a parameter in an unix shellscript
>which is wrapped around the whole thing.
>
>If anyone can help with the set parameters to reach the aim, I would be
>so glad.
>
>Carsten
>

Tom Kite has some PL/SQL code to do this. Might be worth a look. <http://asktom.oracle.com/pls/ask/f?p=4950:8:11915701242614200387::NO::F4 950_P8_DISPLAYID,F4950_P8_CRITERIA:88212348059>

-- 
Jim Smith
Because of their persistent net abuse, I ignore mail from
these domains (among others) .yahoo.com .hotmail.com .kr .cn .tw
For an explanation see <http://www.jimsmith.demon.co.uk/spam>
Received on Tue Aug 09 2005 - 10:39:27 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US