注释可以使应用程序更易于阅读和维护。例如,您可以在语句中用注释以描述该语句在应用程序中的用途。除 Hint 外,SQL 语句中的注释不会影响语句的执行。
注释可以出现在语句中的任何关键字、参数或标点符号之间。您可以通过两种方式在语句中添加注释:
一个 SQL 语句可以同时包含这两种风格的多个注释。注释的文本可以包含数据库字符集中的任何可打印字符。
以下示例展示了多种形式的以斜杠和星号(/*)为开头的注释:
SELECT last_name, employee_id, 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 salary + commission_pct */
FROM employees
WHERE last_name = 'Pataballa')
ORDER BY last_name, employee_id;
以下示例中的语句包含多种形式的以两个连字符(- -)为开头的注释:
SELECT last_name, -- select the name
employee_id -- employee id
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
ORDER BY last_name -- and order by last name
employee_id -- and employee id.
;
备案信息: 粤ICP备15087711号-2
Copyright © 2008-2024 啊嘎哇在线工具箱 All Rights.
本站所有资料来源于网络,版权归原作者所有,仅作学习交流使用,如不慎侵犯了您的权利,请联系我们。