码迷,mamicode.com
首页 > 数据库 > 详细

oracle 使用comment语句添加表注释

时间:2015-05-30 10:44:56      阅读:427      评论:0      收藏:0      [点我收藏+]

标签:oracle   comment   

使用oracle comment语句可以给表、字段、视图等对象添加备注信息。


大致语法为:
comment on TABLE table_name IS ‘备注内容‘;


权限要求:
默认情况下用户只能给属于自己的对象添加注释。
如果要想给其他用户对象添加注释需要拥有权限:COMMENT ANY TABLE


相关数据字段视图:
USER_TAB_COMMENTS
DBA_TAB_COMMENTS
ALL_TAB_COMMENTS
USER_COL_COMMENTS
DBA_COL_COMMENTS
ALL_COL_COMMENTS


示例如下:
drop table t;
create table t(id number);


select * from user_tab_comments;


TABLE_NAME                     TABLE_TYPE                     COMMENTS
------------------------------ ------------------------------ ------------------------------
T                              TABLE


select * from USER_COL_COMMENTS;


SCOTT@orcl> select * from USER_COL_COMMENTS WHERE table_name=‘T‘;


TABLE_NAME                     COLUMN_NAME                    COMMENTS
------------------------------ ------------------------------ ------------------------------
T                              ID




--添加注释
SCOTT@orcl> comment on table t is ‘测试表T‘;


注释已创建。


SCOTT@orcl> comment on column t.id is ‘行ID‘;


注释已创建。


SCOTT@orcl> select * from user_tab_comments WHERE table_name=‘T‘;


TABLE_NAME                     TABLE_TYPE                     COMMENTS
------------------------------ ------------------------------ ------------------------------
T                              TABLE                          测试表T


SCOTT@orcl> select * from USER_COL_COMMENTS WHERE table_name=‘T‘;


TABLE_NAME                     COLUMN_NAME                    COMMENTS
------------------------------ ------------------------------ ------------------------------
T                              ID                             行ID




详细文章请参考:http://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_4009.htm#i2119719



























oracle 使用comment语句添加表注释

标签:oracle   comment   

原文地址:http://blog.csdn.net/indexman/article/details/46272093

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!