SQLPlus Review
SQLPlus Review
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
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
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;
Typed at the SQL prompt, displays a list of all available tables for the current user.
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.