zoukankan      html  css  js  c++  java
  • oracle comment on的用法

    转:http://www.2cto.com/database/201109/106249.html

    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    

     

     

  • 相关阅读:
    17张程序员壁纸推荐,是否有一张你喜欢的?
    学会了这些英文单词,妈妈再也不用担心我学不会Python
    小白学习Python英语基础差怎么办,都帮你想好拉!看这里
    自动化测试学习防踩坑手册,测试人员人手一份
    Selenium自动化结合Mysql数据项目实战操作
    解除你学习Python自动化测试框架的所有疑惑,开启学习直通车
    数据库管理软件navicate12的激活和安装
    修改文件版本号方法
    Json的数据映射(基于LitJson)
    VMware 虚拟机安装黑屏问题
  • 原文地址:https://www.cnblogs.com/xudj/p/11720203.html
Copyright © 2011-2022 走看看