加入收藏 | 设为首页 | 会员中心 | 我要投稿 好传媒网 (https://www.haochuanmei.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 运营中心 > 网站设计 > 教程 > 正文

oracle comment命令用法示例分享

发布时间:2021-12-28 09:39:07 所属栏目:教程 来源:互联网
导读:oracle中用comment on命令给表或字段加以说明,语法如下: 复制代码 代码如下: COMMENT ON { TABLE [ schema. ] { table | view } | COLUMN [ schema. ] { table. | view. | materialized_view. } column | OPERATOR [ schema. ] operator | INDEXTYPE [ sche
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

(编辑:好传媒网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    热点阅读