0% found this document useful (0 votes)
31 views

SQLPlus Review

This document provides instructions for creating and running script files, spooling output files, and logging into SQL*Plus using the default SCOTT account. It describes two methods for creating script files: using the EDIT command at the SQL prompt or creating the file in Notepad. It also explains how to use spooling to capture SQL commands and results to an output file and how to spool an existing script file. Additional tips covered include using comments, describing tables, listing available tables, and reusing SQL statements.

Uploaded by

copadi
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views

SQLPlus Review

This document provides instructions for creating and running script files, spooling output files, and logging into SQL*Plus using the default SCOTT account. It describes two methods for creating script files: using the EDIT command at the SQL prompt or creating the file in Notepad. It also explains how to use spooling to capture SQL commands and results to an output file and how to spool an existing script file. Additional tips covered include using comments, describing tables, listing available tables, and reusing SQL statements.

Uploaded by

copadi
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

SQL*Plus Review

CREATING A SCRIPT FILE

Method 1) At the SQL prompt, type EDIT C:filename


--takes you to the default editor (Notepad)
--type your script and close the Notepad file
--You do not have to give a file extension, Oracle saves with a sql extension
To run the script:
At the SQL prompt, type @C:filename

Method 2)
Open Notepad and create your script
--When saving the script file, in the SAVE AS dialog box, enclose the filename in
double quotes so Notepad does not add a txt extension. Ex: "ch2script.sql"
To run the script:
At the SQL prompt, type @C:filename

SPOOLING A FILE

Spooling allows you to show your SQL commands and their results.
To turn spooling on:
At the SQL prompt, type SPOOL C:filename
Type and execute your SQL statements in SQL*Plus
When finished, type SPOOL OFF
The spooled file can then be opened in Notepad, WordPad, Word, etc. and printed

SPOOLING A SAVED SCRIPT FILE

At the SQL prompt, type SPOOL C:filename (the name you want to give your
spooled file)
At the SQL prompt, to run your script, type @C:filename (the name of your
script file)
After your script file runs, type SPOOL OFF
The spooled file can then be opened in Notepad, WordPad, Word, etc. and printed

NOTE:
You cannot append to a spooled file. If you spool to the same filename more than once,
the original file will be overwritten!

Before you spool, check the SQL*Plus environment to make sure that ECHO is on. If it
is not turned on, the results of your SQL statements will appear in your spooled file, but
your actual SQL statements may not appear. To turn ECHO on, at the SQL prompt, type
the following command: SET ECHO ON;
LOGGING ON TO DEFAULT ACCOUNT

User Name: SCOTT


Password: TIGER

CL SCR
Typed at the SQL prompt, clears the screen.

ED
Typed at the SQL prompt, takes you to the editor where you can make revisions to the
last SQL statement typed.

--
A double hyphen is used in script files for a single comment line.

DESC

Typed at the SQL prompt, describes the structure of a table. EX: DESC DEPT;

SELECT * FROM CAT;

Typed at the SQL prompt, displays a list of all available tables for the current user.

REUSING A SQL STATEMENT

In a SQL*Plus session, to reuse a previously typed SQL statement, select the statement
using the left mouse button; continue to press the left mouse button as you click the right
mouse button. The SQL statement will be copied to the SQL prompt line.

You might also like