Comments
You can associate comments with SQL statements and schema objects.
Comments Within SQL Statements
Comments within SQL statements do not affect the statement execution, but they may make your application easier for you to read and maintain. You may want to include a comment in a statement that describes the statement's purpose within your application.
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:
- Begin the comment with a slash and an asterisk (/*). Proceed with the text of the comment. This text can span multiple lines. End the comment with an asterisk and a slash (*/). The opening and terminating characters need not be separated from the text by a space or a line break.
- Begin the comment with -- (two hyphens). Proceed with the text of the comment. This text cannot extend to a new line. End the comment with a line break.
A SQL statement can contain multiple comments of both styles. The text of a comment can contain any printable characters in your database character set.
These statements contain many comments:
SELECT last_name, salary + NVL(commission_pct, 0),
/* Select all employees whose compensation is
greater than that of Pataballa.*/
FROM employees e, departments d
/*The DEPARTMENTS table is used to get the department name.*/
WHERE e.department_id = d.department_id
AND salary + NVL(commission_pct,0) > /* Subquery: */
(SELECT salary + NVL(commission_pct,0)
/* total compensation is salar + commission_pct */
WHERE last_name = 'Pataballa');
SELECT last_name, -- select the name
salary + NVL(commission_pct, 0),-- total compensation
e.department_id -- and department
FROM employees e, -- of all employees
WHERE e.department_id = d.department_id
AND salary + NVL(commission_pct, 0) > -- whose compensation
(SELECT salary + NVL(commission_pct,0) -- the compensation
WHERE last_name = 'Pataballa') -- of Pataballa.
You can associate a comment with a table, view, materialized view, or column using the COMMENT command. Comments associated with schema objects are stored in the data dictionary.