一、獲取某個(gè)用戶下Oracle某個(gè)表行記錄的長(zhǎng)度
這個(gè)長(zhǎng)度是表字段定義的長(zhǎng)度,獲取方法:
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 wner=upper('用戶名')
group by rollup((owner, table_name, column_name, data_type, data_length))
二、根據(jù)表數(shù)據(jù)所占總字節(jié)數(shù)和表記錄數(shù)來(lái)獲取實(shí)際的每行記錄的平均長(zhǎng)度
獲取表數(shù)據(jù)的所有字節(jié)數(shù):
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;
獲取表總記錄數(shù):
select count(*) from 表名
兩者求商即得每行記錄的平均字節(jié)數(shù)。