Its an interesting question, to be sure. Most people who are familiar with Oracle development wouldn't give it a thought but when you come down to it, its sometimes confusing to define the demarcation between SQL and PL/SQL.
By looking at the definition of the acronyms, you start to get an idea of what areas of functionality each covers:
SQL - Structured Query Language
PL/SQL - Procedural Language / Structured Query Language
The observant reader might notice how SQL shows up twice 8) That's because SQL is often embedded within PL/SQL - PL/SQL is a language that was made to provide a proprietary 4th generation language (4GL) that plays very well with database objects in Oracle.
Wikipedia has some pretty good material on both SQL and PL/SQL
The confusing part is where PL/SQL and SQL overlap a bit. SQL's purview includes data insert, query, update and delete, the so-called DML, or data manipulation language operations, but it also includes create, alter, rename, drop which are DDL or data definition language operations. Its here where some might get confused. The operation to create a stored procedure, something written using PL/SQL, is actually SQL - you use SQL to create the database object that represents a block of PL/SQL.
Likewise, you can embed SQL code inside your PL/SQL. A FOR loop in PL/SQL can be based upon a SQL query, for example. Blows your mind a little, eh? You create a procedure using SQL that actually internally uses SQL to perform some action on records from the database.
Cool stuff if you ask me.
There is no difference for a single SQL statement. The '/' character on its own line tells SQL*Plus to execute the command in the buffer. You can use the semicolon at the end of most SQL statements as a shorthand for the '/'. If you want to execute a PL/SQL block or to execute a handful of SQL statements like CREATE TYPE
, however, you need to use the '/'
SQL> begin
2 null;
3 end;
4 /
PL/SQL procedure successfully completed.
SQL> create type foo as object (
2 col1 number,
3 col2 number );
4 /
Type created.
Different tools may have slightly different conventions for how you execute multiple SQL and PL/SQL statements in a script so be aware that this is SQL*Plus specific.
Best Answer
The difference is that
--
and/* */
can be used in a PL/SQL block, whileREM[ARK]
cannot. The following will work in SQL*Plus:These will not:
The 11.2 documentation on all comment types has more comment information. The basics are...
The documentation also includes notes on four places that comments should not be used, but these do not include any further differences.