Why does Oracle SQL*Plus consider two queries executed together on the command line as a syntax error

oracle

Consider:

SQL> select sysdate from dual;

SYSDATE
-----------
22-Aug-13 0

SQL> select sysdate from dual; select sysdate from dual;

select sysdate from dual; select sysdate from dual

ORA-00911: invalid character

SQL> 

Notice that when I execute two queries at once in the command window, it throws the ORA-00911: invalid character error which generally indicates syntactic error.

Best Answer

It is a syntax error.

SQL*Plus expects either:

  • A single SQL command, terminated by either a ";" character or a "/" on a line by itself.
  • A PL/SQL block
  • A SQL*Plus command

What you have entered is 2 queries on a single line, which SQL*Plus will send to the RDBMS - Oracle will then try and parse the string sent as a single query and fail because it is not valid SQL.

See the documentation for more details: http://docs.oracle.com/cd/E11882_01/server.112/e16604/ch_four.htm#i1039424