When you're entering an SQL statement into SQL*Plus, it needs to know when you're done with it, especially if the command spans multple rows. Therefore, it requires a terminal character character which can be set with the set sqlterminator
. By default, this character is the semicolon:
SQL> select *
2 from
3 dual;
D
-
X
Now, changing this terminal character to a #
:
SQL> set sqlterminator #
SQL> select *
2 from
3 dual#
D
-
X
The SQL statement was ended (end executed) with a #
.
You ask: why was set sqlterminator #
not followed by a semicolon? Answer, because this is not an SQL statement. Statements that relate to SQL*Plus and its behaviour, output, connection asf (such as set echo on
and connect system/manager
) are not SQL statements and are therfore entered without the semicolon.
What has this to do with the /
?
When you entered an SQL statement, SQL*plus filled something what it calls a buffer. This buffer can be shown with the list
command:
SQL> list
1 select *
2 from
3* dual
SQL>
(Note: I only entered list, the rest is returned)
The /
now executes what is currently in the buffer. Lets try that:
SQL> /
D
-
X
As can be seen, the same query is executed.