SQL*Plus Tutorial

The most important commands available in SQL * Plus:

ACCEPT – read a variable input from the user;

DEFINE – declares a variable (DEF);

DESCRIBE – lists the attributes of the tables or other objects (DESC);

EDIT - opens an editor in which you can change the last command;

EXIT or QUIT – disconnects the user and SQL * Plus session;

GET - searches for a file in SQL and submits SQL buffer;

HOST – running an operating system command (!);

LIST - shows the last command executed SQL buffer (L);

PROMPT - displays a text on the screen;

RUN - lists and runs the command that is saved in the SQL buffer (/);

SAVE – save buffer command into a SQL script file;

SET - change environment variables specific to SQL * Plus;

SHOW - displays the environment variables settings in SQL * Plus;

SPOOL - copies the output of a command to a file;

START – run a SQL script.



SQL * Plus Interactive commands

PAUSE command allows you to display a blank line or a text by temporary suspension of action and waiting for a RETURN to the user;

PROMPT command sends a blank line or a message on the screen;

ACCEPT command line allows the reading on the screen and its a variable value assignment specified.

ACCEPT variable [NUMBER | CHAR | DATA]
[FORMAT format] [PROMPT text | NOPROMPT] [HIDE]

Observations:
- the type of the variable's default is CHAR;
- text of the PROMPT is printed before the user to give the actual value;
- the option HIDE makes the value given by the user to be hidden;
- option indicates the format string FORMAT;
- variable substitution, if present, must not be use with the symbol "&".

Example:
ACCEPT Alpha PROMPT ' number of copies: '
ACCEPT beta PROMPT ' author name ':
SELECT *
FROM the book
WHERE nrex = & alpha
AND author = ' & ' beta;