Skip to Main Content
Oracle SQL*Plus: The Definitive Guide
book

Oracle SQL*Plus: The Definitive Guide

by Jonathan Gennick
March 1999
Intermediate to advanced content levelIntermediate to advanced
528 pages
14h 39m
English
O'Reilly Media, Inc.
Content preview from Oracle SQL*Plus: The Definitive Guide

Saving and Retrieving the Buffer

SQL*Plus allows you to save the contents of the buffer to a file and to read that file back again. If you have built up a long and complicated SQL statement, you can save it for reuse later, and save yourself the bother of figuring it all out again. Two commands, GET and SAVE, are provided for this purpose.

SAVE

The SAVE command allows you to save the current contents of the buffer to a file. Here is the syntax for SAVE:

SAVE filename [CREATE|REPLACE|APPEND]

where:

SAV[E]

May be abbreviated SAV.

filename

Is the name of the file to which you want to save the buffer. The default extension is .SQL, but you may specify another if you like.

CRE[ATE]

Tells SQL*Plus that you want to create a new file. The save will fail if the file you’ve specified already exists. This is the default behavior.

REPLACE

Tells SQL*Plus to save the buffer to the file specified, regardless of whether or not that file already exists. If the file does exist, it will be overwritten.

APPEND

Tells SQL*Plus to add the contents of the buffer to an existing file.

The following example shows the SAVE command being used to save the contents of a rather long SQL query to a file. First the query is entered into the buffer without being executed; then the SAVE command is used to write the buffer to a file.

SQL>   SELECT employee_name,  project_name
  2      FROM employee, project, project_hours
  3     WHERE employee.employee_id = project_hours.employee_id
  4       AND project_hours.project_id = project.project_id 5  ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Oracle SQL*Plus: The Definitive Guide, 2nd Edition

Oracle SQL*Plus: The Definitive Guide, 2nd Edition

Jonathan Gennick
Oracle PL/SQL Programming, Third Edition

Oracle PL/SQL Programming, Third Edition

Steven Feuerstein, Bill Pribyl
Oracle SQL

Oracle SQL

Dan Hotka

Publisher Resources

ISBN: 1565925785Supplemental ContentCatalog PageErrata