Basic elements of Oracle SQL comments

Source: Internet
Author: User
Tags printable characters

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 in multiple comments of both styles. The text of a comment can contain in any printable characters in your database character set.

Example

These statements contain your comments:

Select last_name, salary + nvl (commission_pct, 0 ),

Job_id, E. department_id

/* 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 */

From employees

Where last_name = 'pattera ');

 

Select last_name, -- select the name

Salary + nvl (commission_pct, 0), -- total compensation

Job_id, -- job

E. department_id -- and Department

From employees e, -- of all employees

Administrative ments d

Where E. department_id = D. department_id

And salary + nvl (commission_pct, 0)> -- whose compensation

-- Is greater

(Select salary + nvl (commission_pct, 0) -- The Compensation

From employees

Where last_name = 'pattera') -- of pataballa.

;

Comments on schema objects

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.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.