What does # mean in sqlplus?

The script used to be

shutdown abort

it has been replaced by

#shutdown abort
shutdown immediate

Let’s try !


SQL> #shutdown abort
ORACLE instance shut down.
SQL> shutdown immediate
ORA-01012: not logged on

sqlplus just silently ignored the # symbol and executed the first statement.

Thanks to Maxim comment, here is a new case to explain the sql prefix #

SQL> sho sqlpre
sqlprefix "#" (hex 23)
SQL> select
2 #prompt hello world
hello world
2 * from dual;

D
-
X

While within (or outside of) an sqlplus block, you can tell sqlplus to immediately run a sqlplus statement

The correct syntaxes to put comment are documented in Placing Comments in Scripts

SQL> remark shutdown abort
SQL> rem shutdown abort
SQL> -- shu abort
SQL> /* shutdown abort */

5 thoughts on “What does # mean in sqlplus?

  1. Oleksanndr

    Nice feature! 😉
    another interesting usage of this “comment”

    SQL> select owner,count(*)
    2 from dba_objects
    3 #shutdown abort
    ORACLE instance shut down.
    3 group by owner;
    select owner,count(*)
    *
    ERROR at line 1:
    ORA-01034: ORACLE not available
    Process ID: 26848
    Session ID: 143 Serial number: 2467

  2. Gary Pennington

    Hi, I tend to use #desc when I am halfway through writing a select but have forgotten a column name. Then I can just carry on with the rest of my select. Very useful.

  3. Laurent Schneider Post author

    Really, I will think about it.
    I used to
    .[ENTER]
    desc bla[ENTER]
    i[ENTER]

    but why not #desc 😉 it is actually much shorter to type !!!

Comments are closed.