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: Sample Script?

Re: Sample Script?

From: Terry Dykstra <tddykstra_at_forestoil.ca>
Date: Thu, 20 Dec 2007 17:18:13 GMT
Message-ID: <ptxaj.29068$UZ4.10374@edtnps89>


"AP" <megacrosstab_at_greenixsolutions.com> wrote in message news:da5f0cf2-5409-4c39-abf8-c93d19ddcb07_at_q3g2000hsg.googlegroups.com...
> On Dec 20, 10:48 am, "Terry Dykstra" <tddyks..._at_forestoil.ca> wrote:
>> "AP" <megacross..._at_greenixsolutions.com> wrote in message
>>
>> news:804a246f-3fca-4b54-a2bc-aeecac1841eb_at_j20g2000hsi.googlegroups.com...
>>
>> > Hello I am new to Oracle. What I am trying to do is basic, I think. I
>> > typically use toad to run select statements. I want to be able to
>> > create a script that simply when executed, runs the select statement
>> > and exports it to a file. Once I get this figured out, I would use a
>> > command line method to run it on a scheduled basis. Any samples ?
>>
>> > Thanks
>>
>> In its most basic form:
>>
>> sqlplus userid/passwd_at_dbname @yourscript.sql
>>
>> with a spool statement in the yourscript.sql file.
>>
>> Hardcoding passwords obviously is not very good. There are ways of
>> redirecting input from another file into your script.
>> --
>> Terry Dykstra
>
> Thanks for the reply, but I know the command line part, I do not know
> how to do the following:
>
>
> Select * from mytable;
>
> Save the output as txt to C:\output files.
>
>
> Not sure how to build the script.
> Thanks for your response.
>

Using spool:

spool myfile.txt
select a,b,c from mytable;
spool off

Check out the sqlplus user guide.

-- 
Terry Dykstra 
Received on Thu Dec 20 2007 - 11:18:13 CST

Original text of this message

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