统计数据库表结构

select 
UTCC.COMMENTS as "表名",
UT.TABLE_NAME as "表英文名",
'' as "所属服务",
UTC.COLUMN_NAME as "字段名",
case 
  when UTC.DATA_TYPE = 'VARCHAR2' 
    then UTC.DATA_TYPE || '(' || UTC.DATA_LENGTH || ')'
  when UTC.DATA_TYPE = 'NUMBER' and UTC.DATA_PRECISION is not null and UTC.DATA_SCALE is not null 
    then UTC.DATA_TYPE || '(' || UTC.DATA_PRECISION || ',' || UTC.DATA_SCALE || ')'
  else UTC.DATA_TYPE
end as "字段类型",
UCC.COMMENTS as "字段说明"
from user_tables UT
left join user_tab_columns UTC on UTC.TABLE_NAME = UT.TABLE_NAME
left join user_tab_comments UTCC on UTCC.TABLE_NAME = UT.TABLE_NAME
left join user_col_comments UCC on UCC.TABLE_NAME = UTC.TABLE_NAME and UCC.COLUMN_NAME = UTC.COLUMN_NAME
where UT.TABLE_NAME in()
order by UT.TABLE_NAME,UTC.NULLABLE

 

posted @ 2023-01-06 15:57  涂山有雨  阅读(33)  评论(0编辑  收藏  举报