Working with SQL:

When you go to Oracle, you want to go in with SQL - different things will be indicated depending on the version you are working with. You will then be prompted to enter the username, password and if you are working on a server, you will need to enter the database connect string.

When you enter a SQL statement, it is stored in a SQL buffer where it remains there until a new statement is entered. That means you can enter the word edit at the SQL prompt and go into notepad where you can enter the contents of the buffer. On leaving you save and exit. Back at the SQL prompt, you enter / to execute the code in the buffer.

If you want to look at the table structure to check on field types or other information, you can use the command DESCRIBE (which can be abbreviated to DESC) followed by the table name. The structure will be displayed.

DESCRIBE donor;

The EDITING commands that are available in SQL are entered individually on one line and not stored in the buffer. You can continue on a second line by placing a hyphen at the end of the line and then pressing enter to go to the next line. After editing is complete, to return to the SQL prompt, you can enter one of the terminator characters (the semi colon to view the command or the slash to attempt execution).

EDITING COMMANDS:

The EDITING commands that are available in SQL are entered individually on one line and not stored in the buffer. You can continue on a second line by placing a hyphen at the end of the line and then pressing enter to go to the next line. After editing is complete, to return to the SQL prompt, you can enter one of the terminator characters (the semi colon to view the command or the slash to attempt execution).

Command Processing
A[PPEND] text Text gets added to the end of the current line
C[HANGE] /text/ Deletes the specified text from the current line
C[HANGE] /oldtext/newtext Changes the specified old text to the specified new text
CL[EAR] BUFF[ER] Clears the SQL buffer
DEL Deletes the current line
I[NPUT] Inserts lines
I[NPUT] text Inserts the specified text as a line after current line
L[IST] Lists the lines in the SQL buffer
L[IST] n Lists line n in the SQL buffer
L[IST] m n Lists the range of lines m to n in the SQL buffer
n Makes line n the current line
n text Replaces line n with the specified text
0 text Inserts a line at the beginning (before line 1)
R[UN] Displays and executes the code in the SQL buffer
/ Executes the code in the SQL buffer

FILE COMMANDS:

Command Processing
SAV[E] file Saves contents of SQL buffer - default extension is .sql
SAV[E] file REP[LACE] Saves contents of SQL buffer overwriting existing file
SAV[E] file APP[END] Saves contents of SQL buffer by adding to existing file
GET file Writes file to SQL buffer - default extension is .sql
STA[RT] or @filename Runs/executes contents of saved command file
ED[IT] Brings up editor (notepad) to edit contents of SQL buffer - saves to aftedt.buf
ED[IT] file Brings up editor to edit saved file
SPO[OL] file [OFF|OUT] Stores query results in a file. OFF closes spool file and OUT closes and sends to printer
EXIT Leaves SQL