oracle 表 及字段相关的 统计分析

--结构化数据-数据表

with x as (
select b.COMMENTS 表中文名,u.TABLE_NAME 表名称,b.COMMENTS 表详细描述,u.NUM_ROWS 数据量 from user_tables u left join user_tab_comments b on u.TABLE_NAME=b.TABLE_NAME
)
,y as(
SELECT SEGMENT_NAME TABLE_NAME,
SUM(BYTES)/(1024*1024) "TABLE_SIZE[MB]"
FROM USER_SEGMENTS
WHERE SEGMENT_TYPE='TABLE'
-- AND SEGMENT_NAME=x.TABLE_NAME
GROUP BY SEGMENT_NAME)
select x.*,y."TABLE_SIZE[MB]" 存储空间 from x left join y on x.表名称 = y.TABLE_NAME;

 

 

 

--结构化数据----字段
select tc.COMMENTS 表中文名,c.table_name 表名称,
comm.comments 字段中文名称,
c.column_name 字段名称, c.NUM_DISTINCT 非重复行数,
t.num_rows - c.num_nulls as 非空数据总量
from user_tab_columns c
join user_tables t on c.TABLE_NAME = t.TABLE_NAME
left join user_col_comments comm on comm.table_name = c.table_name and c.column_name = comm.column_name
left join user_tab_comments tc on tc.table_name = t.table_name
where c.table_name = 'table_name'
order by c.column_name

posted @ 2020-01-21 19:24  飞叶-枯寂  阅读(423)  评论(0编辑  收藏  举报