46

Using SqlPlus for Oracle, how do I save the output of a query in a file but not show it on the terminal/prompt.

simplfuzz
  • 12,479
  • 24
  • 84
  • 137
  • 3
    SET TERMOUT OFF is not working wiht my SqlPlus. This sqlplus `-s ${ORA_CONN_STR} </dev/null` i.e. answer by @AshishAnand worked for me. – Sachin Jan 13 '15 at 11:11
  • 3
    "SET TERMOUT is the way to do it and it requires a script - it doesn't do anything at an interactive prompt" - https://community.oracle.com/thread/2140535?tstart=0 – Straff Jan 12 '16 at 23:30

4 Answers4

53

Right from the SQL*Plus manual
http://download.oracle.com/docs/cd/B19306_01/server.102/b14357/ch8.htm#sthref1597

SET TERMOUT

SET TERMOUT OFF suppresses the display so that you can spool output from a script without seeing it on the screen.

If both spooling to file and writing to terminal are not required, use SET TERMOUT OFF in >SQL scripts to disable terminal output.

SET TERMOUT is not supported in iSQL*Plus

Martin Ba
  • 37,187
  • 33
  • 183
  • 337
  • 7
    "SET TERMOUT is the way to do it and it requires a script - it doesn't do anything at an interactive prompt" - community.oracle.com/thread/2140535?tstart=0 – Straff Jan 12 '16 at 23:31
21

Try this:

SET TERMOUT OFF; 
spool M:\Documents\test;
select * from employees;
/
spool off;
Zsolt Botykai
  • 50,406
  • 14
  • 85
  • 110
Mohammad
  • 211
  • 2
  • 2
11

Try This:

sqlplus -s ${ORA_CONN_STR} <<EOF >/dev/null
Ashish Anand
  • 3,531
  • 6
  • 34
  • 45
3

set termout off doesn't work from the command line, so create a file e.g. termout_off.sql containing the line:

set termout off

and call this from the SQL prompt:

SQL> @termout_off
pelms
  • 1,212
  • 1
  • 12
  • 21