Name

SPOOL — Not available in iSQL*Plus

Synopsis

The SPOOL command writes output to a text file. You must use this if you are going to print a report. The only way to print a report is to spool it to a file, then print that file. See Chapter 5 for an example of SPOOL being used to generate a report file. SPOOL may be used to generate a new file of SQL statements to be executed. Chapter 11 shows you how to take advantage of that powerful technique.

Syntax

SP[OOL] file_name [option] | OFF | OUToption ::= {CRE[ATE] | REP[LACE] | APP[END]}

Parameters

SP[OOL]

Is the command, which may be abbreviated SP.

file_name

Is the name of the file to which you want to write the report. The default extension is usually .lst, or sometimes .lis, and it's an operating system-specific value.

OFF

Turns off spooling. You must have turned spooling on before you can turn it off.

OUT

Turns off spooling and prints the file on the default printer. This option isn't available in the Windows versions of SQL*Plus.

CREATE

Requires that a new file be created. If the named file exists, then the SPOOL command aborts with an error.

REPLACE

Replaces an existing file or creates an entirely new file, whichever applies. This represents the default behavior.

APPEND

Adds subsequent output to the end of an existing spool file.

Get Oracle SQL*Plus: The Definitive Guide, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.