Oracle 表的行数、表占用空间大小,列的非空行数、列占用空间大小 查询
--表名,表占用空间大小(MB),行数
select table_name, round(num_rows * avg_row_len /1024/1024, 8) as total_len, num_rows
from user_tables
where table_name = '表名'
order by table_name;
--表名,列名,列占用空间大小(MB),非空行数
select c.table_name, c.column_name, round((t.num_rows - c.num_nulls) * c.avg_col_len /1024/1024, 8) as total_len, t.num_rows - c.num_nulls as nums
from user_tab_columns c
join user_tables t on c.TABLE_NAME = t.TABLE_NAME
where c.table_name = '表名'
order by c.column_name;