RelationalDBDesign RelationalDBDesign


SQL* Plus CLI  «Prev 

Using the SPOOL command

Oracle Spool Command

  1. SPOOL filename: The SPOOL command causes SQL*Plus to start copying its output to the specified file. The extension, if you do not supply one, will usually be ".lis" or ".lst"."
  2. SET TERMOUT OFF: Turns the terminal output off so that you won't see the report scroll by on the screen. This command only works if it is executed from a script. If you are executing commands interactively, it has no effect.
  3. SELECT ...: This is the SELECT statement that produces the report.
  4. SPOOL OFF: SPOOL OFF causes SQL*Plus to close the output file.
  5. SET TERMOUT ON: Reinstates terminal output.

SPOOL

Syntax
SPO[OL] [file_name[.ext] [CRE[ATE] | REP[LACE] | APP[END]] | OFF | OUT]
Stores query results in a file, or optionally sends the file to a printer. Terms
file_name[.ext]
Represents the name of the file to which you wish to spool. SPOOL followed by file_name begins spooling displayed output to the named file. If you do not specify an extension, SPOOL uses a default extension (LST or LIS on most systems). The extension is not appended to system files such as /dev/null and /dev/stderr.
CRE[ATE]
Creates a new file with the name specified.
REP[LACE]
Replaces the contents of an existing file. If the file does not exist, REPLACE creates the file. This is the default behavior.
APP[END]
Adds the contents of the buffer to the end of the file you specify. OFF: Stops spooling.
OUT: Stops spooling and sends the file to your computer's standard (default) printer. This option is not available on some operating systems.
Enter SPOOL with no clauses to list the current spooling status