select distinct TABLE_COLUMN.*,
TABLE_NALLABLE.DATA_TYPE,
TABLE_NALLABLE.NULLABLE
from (select distinct utc.table_name table_name,
utc.comments table_comments,
ucc.column_name column_name,
ucc.comments column_comments
from user_tab_comments utc, user_col_comments ucc
where utc.table_name = ucc.table_name
and utc.table_name not like '%_B'
and utc.table_name not like '%_Z'
and utc.table_name not like '%1%') TABLE_COLUMN,
(select distinct table_name, column_name, nullable, DATA_TYPE
from user_tab_cols
where table_name not like '%_B'
and table_name not like '%_Z'
and table_name not like '%1%') TABLE_NALLABLE
where TABLE_COLUMN.column_name = TABLE_NALLABLE.column_name
and TABLE_COLUMN.TABLE_NAME = TABLE_NALLABLE.table_name;
–导出、生成当前用户的所有表和视图的注释
select 'comment on table '||a.table_name|| ' is '||''''||a.comments||''''||';'
from user_tab_comments a
where a.table_type in('TABLE','VIEW');
–导出、生成当前用户的所有表字段的注释
select 'comment on column '||t.table_name||'.'||t.column_name||' is '||''''||t.comments||''''||';'
from user_col_comments t
–导出、生成所有表的注释(需要dba权限)
select 'comment on table '||t.owner||'.'||t.table_name||' is '||''''||t.comments||''''||';'
from dba_tab_comments t
where t.table_type='TABLE' or t.table_type='VIEW';
–导出、生成所有字段的注释
select 'comment on column '||t.owner||'.'||t.table_name||'.'||t.column_name||' is '||''''||t.comments||''''||';'
–直接生成表名的注释语句
select'comment on table '|| table_name||' IS '''||comments||''';' from user_tab_comments;