学习Oracle的索引、表的存储

本文通过创建表和索引并插入不同长度的数据来测试每个索引键值及表行占用的空间大小,验证了当数据长度超过1024字节后的存储情况。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

每个索引键值 占用1024 字节 ,同样表的每一行也占用1024字节, 如果超过1024字节之后呢? 找时间试试[@more@]
create table t1(x char(1024));
create index ti on t1(x);
insert into t1 values(1);
commit;
begin
for i in 2..7 loop
insert into t1 values(i);
end loop;
end;
/
commit;
begin
for i in 2..7 loop
for j in 3..9 loop
insert into t1 values(i*10+j);
end loop;
end loop;
end;
/
commit;
for i in 2..7 loop
for j in 3..9 loop
insert into t1 values(i*100+j*10+1);
end loop;
end loop;
end;
/
commit;
begin
for i in 22..27 loop
insert into t1 values(i);
end loop;
end;
/
commit;
select file_id,extent_id,block_id,blocks from dba_extents where segment_name='TI';
ANALYZE INDEX TI VALIDATE STRUCTURE;
select btree_space,used_space,pct_used,blocks,lf_blks,br_blks from index_stats;

alter system dump datafile 11 block 858;
alter system dump datafile 11 block 877;
alter system dump datafile 11 block 878;
alter system dump datafile 11 block 88
alter system dump datafile 11 block 879;
每个索引键值 占用1024 字节 , row#0[1822] flag: -----, lock: 0 col 0; len 1024; (1024): 35 34 31 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
....
col 1; len 6; (6): 02 c0 03 5d 00 00
同样表的每一行也占用1024字节,
tl: 1030 fb: --H-FL-- lb: 0x1 cc: 1
col 0: [1024]
35 34 31 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
如果超过1024字节之后呢?
tl: 1585 fb: --H-FL-- lb: 0x1 cc: 2
col 0: [1576]
31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31

参考文章:

http://www.itpub.net/viewthread.php?tid=237710&extra=&page=1

http://www.eygle.com/archives/2005/02/ecibtreeeeoaeoe.html

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/9614263/viewspace-1007520/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/9614263/viewspace-1007520/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值