Oracle 各种注释

[color=red][b]为SQL语句添加注释:[/b][/color]
[img]http://docs.oracle.com/cd/B19306_01/appdev.102/b14261/comment.gif[/img]
[url]http://docs.oracle.com/cd/B19306_01/appdev.102/b14261/comments.htm#sthref2572[/url]
[url]http://docs.oracle.com/cd/B19306_01/server.102/b14200/sql_elements006.htm#i31713[/url]
单行注释 用 [color=red]--[/color]comment text
多行注释 用 [color=red]/*[/color] comment txt [color=red]*/[/color]


[color=red][b]使用 COMMENT ON ..IS 'text'语句为表、列、视图等添加注释:[/b][/color]
[url]http://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_4009.htm#i2119719[/url]
[img]http://docs.oracle.com/cd/B19306_01/server.102/b14200/img/comment.gif[/img]
[url]http://www.adp-gmbh.ch/ora/sql/comment.html[/url]

comment on table some_table is 'some hopefully meaningful comment for some_table';
comment on table some_view is 'Views can also be commented, yet the statement is still: comment on table';
comment on column some_table.col_1 is 'Be sure to really give some meaningful comment';
comment on column some_view.col_1 is 'Useless, or wrong comments, are worse than no comment at all';



[color=red][b]为PL/SQL的输出结果添加注释:[/b][/color]
[url]http://stackoverflow.com/questions/193107/print-text-in-oracle-sql-developer-sql-worksheet-window[/url]
将PL/SQL语句也输出到其执行后的输出结果中,方便对输出结果的查看,不至于混乱。方法很多:
[b]1[/b] 使用 SET ECHO ON[quote]
set echo on
select distinct deptno from dept;
select distinct deptno from emp;
执行后的输出:[quote]SQL> select distinct deptno from dept

DEPTNO
----------
10
20
30
40

4 rows selected.
SQL> select distinct deptno from emp

DEPTNO
----------
30
20
10

3 rows selected.
[/quote][/quote]
[b]2[/b] 使用REM(remark)(前提是得SET ECHO ON)[quote]
set echo on
REM CommentFor Dept Select
select distinct deptno from dept;
select distinct deptno from emp;
执行后的输出:[quote]SQL> REM CommentFor Dept Select
SQL> select distinct deptno from dept

DEPTNO
----------
10
20
30
40

4 rows selected.
SQL> select distinct deptno from emp

DEPTNO
----------
30
20
10

3 rows selected.[/quote][/quote]
[b]3[/b] 结合使用 SET SERVEROUTPUT ON和存储过程输出函数DBMS_OUTPUT.put_line[quote]
SET SERVEROUTPUT ON
execute DBMS_OUTPUT.put_line('Dept Comment');
select distinct deptno from dept;
execute DBMS_OUTPUT.put_line('Emp Comment');
select distinct deptno from emp;
执行后的输出:[quote]Dept Comment
PL/SQL procedure successfully completed.

DEPTNO
----------
10
20
30
40

4 rows selected.
Emp Comment
PL/SQL procedure successfully completed.

DEPTNO
----------
30
20
10

3 rows selected.
[/quote][/quote]
[b]4[/b] 使用 PROMPT[quote]
PROMPT Dept Comment
select distinct deptno from dept;
PROMPT Emp Comment
select distinct deptno from emp;
执行后的输出:[quote]Dept Comment

DEPTNO
----------
10
20
30
40

4 rows selected.
Emp Comment

DEPTNO
----------
30
20
10

3 rows selected.[/quote][/quote]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值