一、获取某个用户下某个表行记录的长度
这个长度是表字段定义的长度,获取方法:
- select owner,
- table_name,
- column_name,
- data_type,
- data_length,
- sum(case data_type
- when 'DATE' then
- 7
- when 'NUMBER' then
- 22
- else
- data_length
- end) length
- from all_tab_cols
- where table_name = upper('表名')
- and DATA_TYPE
- and owner=upper('用户名')
- group by rollup((owner, table_name, column_name, data_type, data_length))
二、根据表数据所占总字节数和表记录数来获取实际的每行记录的平均长度
获取表数据的所有字节数:
- select segment_name,
- segment_type,
- nvl(sum(bytes), 0)
- from user_segments
- where segment_type = 'TABLE'
- and segment_name = '表名'
- group by segment_name, segment_type
- order by 3 desc;
获取表总记录数:
- select count(*) from 表名
两者求商即得每行记录的平均字节数。
本文转自 leizhimin 51CTO博客,原文链接:http://blog.51cto.com/lavasoft/383367,如需转载请自行联系原作者