A comment can appear between any keywords, parameters or punctuation marks in a statement. You can include a comment in a statement using either of these means:
You can use comments in a SQL statement to pass instructions, or hints, to the Oracle7 optimizer. The optimizer uses these hints to choose an execution plan for the statement. For more information on hints, see the "Tuning SQL Statements" chapter of Oracle7 Server Tuning.
Note that you cannot use these styles of comments between SQL statements in a SQL script. You can use the Server Manager or SQL*Plus REMARK command for this purpose. For information on these commands, see Oracle Server Manager User's Guide or SQL*Plus User's Guide and Reference.
Example
These statements contain many comments:
SELECT ename, sal + NVL(comm, 0), job, loc
/* Select all employees whose compensation is
greater than that of Jones.*/
FROM emp, dept
/*The DEPT table is used to get the department name.*/
WHERE emp.deptno = dept.deptno
AND sal + NVL(comm,0) > /* Subquery: */
(SELECT sal + NLV(comm,0)
/* total compensation is sal + comm */
FROM emp
WHERE ename = 'JONES')
SELECT ename, -- select the name
sal + NVL(comm, 0) -- total compensation
job -- job
loc -- and city containing the office
FROM emp, -- of all employees
dept
WHERE emp.deptno = dept.deptno
AND sal + NVL(comm, 0) > -- whose compensation
-- is greater than
(SELECT sal + NVL(comm,0) -- the compensation
FROM emp
WHERE ename = 'JONES') -- of Jones.