Categories
dba sqlplus

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 */

By Laurent Schneider

Oracle Certified Master

5 replies on “What does # mean in sqlplus?”

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

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.

Leave a Reply

Your email address will not be published.