ERP俱乐部
ERP爱好者、ERP从业者互相交流、互相学习的乐园;我们的愿景是成为全球一流的中文ERP(Enterprise Resource Planning)交流平台
网站首页 论坛首页 搜索 用户列表 FAQ 注册 登录  
ERP俱乐部 -> 数据库专栏 -> Oracle数据库 -> oracle comment on的用法
  oracle comment on的用法
帖子发起人: weilm   发起时间: 2012-08-07 03:37 下午   回复数: 0
? 上一主题 下一主题 ?
楼主
  2012-08-07, 03:37 下午
weilm 离线,最后访问时间: 2012/12/31 15:25:15 weilm

发帖数前150位
男

80级
等级: 80级
注册: 2012年4月17日
区域: 广东深圳
经验: 1,183
积分: 1,163
精华: 0
发贴: 158
排名: 28
Site Registered Users
oracle comment on的用法
 
oracle中用comment on命令给表或字段加以说明,语法如下:
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';

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

TABLE_NAME                     TABLE_TYPE  COMMENTS
------------------------------ ----------- ----------
EMPLOYEES                      TABLE       员工表

SQL> select * from user_tab_comments where comments is not null;

TABLE_NAME                     TABLE_TYPE  COMMENTS
------------------------------ ----------- --------------------------
EMPLOYEES                      TABLE       员工表

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

TABLE_NAME                     COLUMN_NAME                    COMMENTS
------------------------------ ------------------------------ ------------
EMPLOYEES                      EMPLOYEE_ID                   
EMPLOYEES                      MANAGER_ID                    
EMPLOYEES                      FIRST_NAME                    
EMPLOYEES                      LAST_NAME                     
EMPLOYEES                      TITLE                         
EMPLOYEES                      SALARY                         员工薪水

SQL> select * from user_col_comments where comments is not null;

TABLE_NAME                     COLUMN_NAME                    COMMENTS
------------------------------ ------------------------------ -------------
EMPLOYEES                      SALARY                         员工薪水

5.我们也可以从下面这些视图中查看表级和列级说明:
ALL_COL_COMMENTS
USER_COL_COMMENTS
ALL_TAB_COMMENTS
USER_TAB_COMMENTS

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

SQL> select * from user_tab_comments where TABLE_NAME='EMPLOYEES';

TABLE_NAME                     TABLE_TYPE  COMMENTS
------------------------------ ----------- -------------
EMPLOYEES                      TABLE     

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

SQL> select * from user_col_comments where TABLE_NAME='EMPLOYEES';

TABLE_NAME                     COLUMN_NAME                    COMMENTS
------------------------------ ------------------------------ -------------
EMPLOYEES                      EMPLOYEE_ID                   
EMPLOYEES                      MANAGER_ID                    
EMPLOYEES                      FIRST_NAME                    
EMPLOYEES                      LAST_NAME                     
EMPLOYEES                      TITLE                         
EMPLOYEES                      SALARY   

世界上最远的距离是知与行的距离
分享按钮 IP 地址: 已登录   来自: 已登录    返回顶部
 第 1 页 总共 1 页 [共有 1 条记录]
ERP俱乐部 -> 数据库专栏 -> Oracle数据库 -> oracle comment on的用法
(C)Copyright 2005-2020 www.erpclub.org All Rights Reserved.
Tel:+86-755-26444630
Email:webmaster@yok.com.cn