0

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

2
  • / signifies GO command for SQLPLUS (to start execution). However SQL Developer uses JDBC to execute all code, so trailing / is not required (it is a sqlplus construct). Basic requirements of a complete PL/SQL valid code block still apply to both tools. Semicolon (;) signifies end of statement (or end of block depending where and how it is used) in PLSQL so it is applicable to both tools. – Raj Mar 23 '16 at 18:55
  • 1
    Neither SQL*Plus nor SQL Dev execute SQL or PL/SQL. They send it to the database to be executed by the appropriate engine within the database. The use of ';' or '/' by the the tool (sqlplus or SQL Dev or Toad or ... or ..) is a matter of how the tool was coded. Note that the use of ';' within a PL/SQL block is a matter of the Pl/SQL language itself. "What's the proper way to code a script?" That's not even an Oracle question. The proper way to code any script depends on what program is processing the script. – EdStevens Mar 23 '16 at 21:46
0

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).

  • 2
    • 2
      I think that its worth mentioning that the ';' is part of the syntax of a PL/SQL statement/block and as such can't simply be replaced by '/' and wont actually end the statement and run it in the same way that it does with SQL. – BriteSponge Mar 24 '16 at 9:31
    • There seem to be quite a few differences in SQL*Plus and SQL Developer besides this specific difference. But I'll accept this for now. – MacGyver Mar 30 '16 at 18:05

    Your Answer

    By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

    Not the answer you're looking for? Browse other questions tagged or ask your own question.