Basic Elements of Oracle SQL 之 Comments

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.

Example

These statements contain many 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 = 'Pataballa');

 

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

       departments d

  WHERE e.department_id = d.department_id

    AND salary + NVL(commission_pct, 0) >  -- whose compensation

                                           -- is greater than

      (SELECT salary + NVL(commission_pct,0)  -- the compensation

    FROM employees

    WHERE last_name = 'Pataballa')        -- 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.

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值