[20170206]为什么少1个段.txt
[20170206]为什么少1个段.txt
--前几天的测试,链接:http://blog.itpub.net/267265/viewspace-2133066/
1.环境:
SCOTT@book> @ &r/ver1
PORT_STRING VERSION BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx 11.2.0.4.0 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
CREATE TABLESPACE TEA DATAFILE
'/mnt/ramdisk/book/tea01.dbf' SIZE 100M AUTOEXTEND ON NEXT 1280K MAXSIZE UNLIMITED
LOGGING
ONLINE
EXTENT MANAGEMENT LOCAL UNIFORM SIZE 10M
BLOCKSIZE 8K
SEGMENT SPACE MANAGEMENT AUTO
FLASHBACK ON;
drop table mytest purge;
create table mytest(x number) tablespace tea;
create index i_mytest_x on mytest(x) tablespace tea;
insert into mytest select level from dual connect by level <= 200126;
commit;
2.测试:
SCOTT@book> select * from DBA_FREE_SPACE where file_id=6;
TABLESPACE_NAME FILE_ID BLOCK_ID BYTES BLOCKS RELATIVE_FNO
------------------------------ ---------- ---------- ---------- ---------- ------------
TEA 6 2688 73400320 8960 6
--73400320/1024/1024=70M.
SCOTT@book> column PARTITION_NAME noprint
SCOTT@book> select * from dba_extents where file_id=6;
OWNER SEGMENT_NAME SEGMENT_TYPE TABLESPACE_NAME EXTENT_ID FILE_ID BLOCK_ID BYTES BLOCKS RELATIVE_FNO
------ -------------------- ------------------ --------------- ---------- ---------- ---------- ---------- ---------- ------------
SCOTT MYTEST TABLE TEA 0 6 128 10485760 1280 6
SCOTT I_MYTEST_X INDEX TEA 0 6 1408 10485760 1280 6
--10485760/1024/1024=10M.
--别人问的问题:100-10-10=80,为什么***空间是70M呢?
3.分析:
$ ls -l /mnt/ramdisk/book/tea01.dbf
-rw-r----- 1 oracle oinstall 104865792 2017-02-06 15:34:33 /mnt/ramdisk/book/tea01.dbf
--//实际上建立的文件大小是 100M+8192 = 100*1024*1024+8192=104865792.
--//文件的第0块是OS块,1-127是位图区,这样前面占用1M.
--//如果我增大数据文件1M,这样剩余的9M就可以凑成一个段.
SCOTT@book> ALTER DATABASE DATAFILE '/mnt/ramdisk/book/tea01.dbf' RESIZE 101M;
Database altered.
SCOTT@book> select * from DBA_FREE_SPACE where file_id=6;
TABLESPACE_NAME FILE_ID BLOCK_ID BYTES BLOCKS RELATIVE_FNO
------------------------------ ---------- ---------- ---------- ---------- ------------
TEA 6 2688 83886080 10240 6
--83886080/1024/1024=80M.