views:

127

answers:

3

I am using Solaris. I have to log into sql plus and run some queries, which give a huge result set.

I want to copy all that into a file. Is there any command for it in unix or sqlplus ?

A: 

If you are on the command line then just use the > and 2> to redirect stdout and stderr respectively to log files

func > out.log

Mimisbrunnr
+4  A: 

Use the SPOOL command:

SQL> SPOOL /opt/output

SQL> SELECT ...

SQL> SPOOL OFF
OMG Ponies
+1  A: 

setup Oracle environment

(there are ways around specifying username/password on the command line - not the best way especially when other users can 'ps' on the server and see your password)

sqlplus -s username/password <<-!!
set trimspool on trimout on pages 0 feedback off linesize 1000 echo off verify off
spool file.out
select sysdate from dual;
exit
!!
Stellios