Skip to Content
Oracle SQL*Plus: The Definitive Guide, 2nd Edition
book

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

by Jonathan Gennick
November 2004
Intermediate to advanced
584 pages
15h 29m
English
O'Reilly Media, Inc.
Content preview from Oracle SQL*Plus: The Definitive Guide, 2nd Edition

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 later reuse and save yourself the bother of figuring it all out again. Two commands, SAVE and GET, are provided for this purpose.

SAVE

Example 2-15 shows the SAVE command being used to save the contents of a 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.

Example 2-15. Writing the current buffer contents to a file

SQL> SELECT employee_name, project_name
  2  FROM employee JOIN project_hours
  3       ON employee.employee_id = project_hours.employee_id
  4  JOIN project
  5       ON project_hours.project_id = project.project_id
  6  AND employee_billing_rate IN (
  7         SELECT MAX(employee_billing_rate)
  8         FROM employee)
  9  GROUP BY employee_name, project_name
 10
SQL> SAVE highest_billed_emp_projects
Created file highest_billed_emp_projects.sql

The SAVE command in Example 2-15 creates a new file, with the default extension of .sql, and writes the contents of the buffer to that file. After writing the buffer contents, SQL*Plus writes a trailing forward slash on a line by itself, so the resulting output file looks like this:

SELECT employee_name, project_name FROM employee JOIN project_hours ON employee.employee_id = project_hours.employee_id JOIN project ON project_hours.project_id = project.project_id ...
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.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Oracle SQL*Plus: The Definitive Guide

Oracle SQL*Plus: The Definitive Guide

Jonathan Gennick
Oracle PL/SQL Programming, Third Edition

Oracle PL/SQL Programming, Third Edition

Steven Feuerstein, Bill Pribyl
Oracle PL/SQL Programming, 5th Edition

Oracle PL/SQL Programming, 5th Edition

Steven Feuerstein, Bill Pribyl
Oracle PL/SQL Programming, 6th Edition

Oracle PL/SQL Programming, 6th Edition

Steven Feuerstein, Bill Pribyl

Publisher Resources

ISBN: 0596007469Errata Page