Does PL/SQL code run differently in sql plus vs sql developer

oracleoracle-sql-developerplsqlsqlplus

Today, I stumbled upon a question someone posted about the / character and ; character. The Answer doesn't seem to be down-voted, so I questioned it a little more as to why it wasn't down-voted. Something tells me that sql plus (command line) and sql run via sql developer behave differently. And the usage of these characters is one example Is this true? If so, how can I find these differences?

Reference:

https://stackoverflow.com/questions/1079949/when-do-i-need-to-use-a-semicolon-vs-a-slash-in-oracle-sql

Best Answer

SQL*PLUS and SQL Developer both are client application for Oracle database. These applications just validate the syntax of statements and submit to Oracle Database server for execution. As far as the question is concerned about the uses of / and ; in these application I would like to demostrate as best as I can.

SQL*PLUS

In SQL*PLUS-

  • ; is used to end the current statement.
  • / is used to end current statement as well as If you are in the SQL prompt(SQL>) to run the command which are in the buffer.

    Examples:

    To end and execute the statement-

    SQL> select * from jobs;
    
    SQL> select * from jobs
      2  /
    

    To run the command which is in the buffer(Only the SQL command(not SQL*PLUS command) and the last executed command remains in the buffer).

    SQL> /
    

    Instead, you can use RUN command for the same purpose. The difference is / doesnt show the command being executed but RUN does.

    SQL> RUN
      1* select * from jobs
    

    SQL*PLUS treats PL/SQL program as the SQL command except the ; and the blank line. In normal SQL command if you insert an blank line then it terminates the command as shown below.

    SQL> select * from jobs
       2
    SQL> 
    

    But in PL/SQL block it doesnt terminate the program.

    To terminate and execute the PL/SQL block we use the same /.

    SQL Developer

    In SQL Developer we use CTRL+ENTER or F5 keys to execute commands. We dont need to use ; and / to indicate the end of the command instead we use Run Statement(CTRL+ENTER) or Run Script(F5).