查询表Or列的注释信息

需求:开发人员需要DBA支持,查询表的注释说明,用于明确表的用途。

1.测试

session 1 创建测试表
SQL> create table a_emp as select * from scott.emp;

Table created.

session 2 对测试表dml操作,事务不结束

SQL> insert into a_emp select * from a_emp where rownum=1;

1 row created.

  session 1 对测试表追加注释说明

SQL> comment on table a_emp is '员工信息表';

Comment created.

无需申请锁资源,注释可放心使用


session 1 对测试表的某一列追加注释说明

SQL> comment on column sys.a_emp.empno is '员工编号';

Comment created.

 

2.查询

ALL_TAB_COMMENTS
ALL_COL_COMMENTS
等comments

select * from user_tab_comments where table_name='A_EMP'

TABLE_NAME TABLE_TYPE COMMENTS
-------------------- -------------------- ------------------------------
A_EMP TABLE 员工信息表


select * from user_col_comments where table_name='A_EMP' and COMMENTS is not null


TABLE_NAME COLUMN_NAM COMMENTS
---------- ---------- ------------------------------
A_EMP EMPNO 员工编号

 

3.修改

SQL> comment on column sys.a_emp.empno is 'xx';  --与追加命令相同,无异常

Comment created.

 

posted @ 2018-12-31 18:05  绿茶有点甜  阅读(141)  评论(0编辑  收藏  举报