Oracle comment简介

一、comment是oracle数据库系统的关键字,用于对表,字段添加注释,有利于用户对表结构以及数据库对象含义的理解。

语法如下:
COMMENT ON
  { TABLE [ schema. ]
    { table | view }
  | COLUMN [ schema. ]
    { table. | view. | materialized_view. } column
  | OPERATOR [ schema. ] operator
  | INDEXTYPE [ schema. ] indextype
  | MATERIALIZED VIEW materialized_view
  }
IS 'text' ;

 

用法如下:
1.对表的说明
comment on table table_name is 'comments_on_tab_information';

 

2.对表中列的说明
comment on column table.column_name is 'comments_on_col_information';

 

 

二、用户可以通过数据字典视图来查询表或字段的注释信息,可查询的相应视图为:
1. 访问自己用户的注释信息要查询的数据字典视图(the date directory views)
user_tab_comments;表注释:有三个字段TABLE_NAME,TABLE_TPYE,COMMENTS
user_col_comments;表字段注释:有三个字段TABLE_NAME,CLUMN_NAME,COMMENTS

2. 访问其他用户的注释信息要查询的数据字典视图(the date directory views)
all_tab_comments;表注释:有四个字段OWNER,TABLE_NAME,TABLE_TPYE,COMMENTS
all_col_comments;表字段注释:有四个字段OWNER,TABLE_NAME,CLUMN_NAME,COMMENTS

3. DBA权限用户可访问所有用户的注释信息要查询的数据字典视图(the date directory views):
dba_tab_comments;表注释:有四个字段OWNER,TABLE_NAME,TABLE_TPYE,COMMENTS
dba_col_comments;表字段注释:有四个字段OWNER,TABLE_NAME,CLUMN_NAME,COMMENTS

 

用法如下:

1.查看表的说明
SQL> select * from user_tab_comments where TABLE_NAME='EMPLOYEES';

 

2.查看表中列的说明
SQL> select * from user_col_comments where TABLE_NAME='EMPLOYEES';

 

3.删除表级说明,也就是将其置为空
SQL> comment on table EMPLOYEES is '';

 

4.删除列级说明,也是将其置为空
SQL> comment on column EMPLOYEES.salary is '';

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值