Tablespace and Table 的存储属性设置的实验与理解(五)

2014-11-24 17:27:07 · 作者: · 浏览: 2


PL/SQL procedure successfully completed.



ZN@PROD>exec dbms_stats.gather_table_stats('ZN','TEST5');



PL/SQL procedure successfully completed.



ZN@PROD>exec dbms_stats.gather_table_stats('ZN','TEST6');



PL/SQL procedure successfully completed.



ZN@PROD>select table_name, TABLESPACE_NAME , PCT_FREE ,INITIAL_EXTENT ,NEXT_EXTENT ,MIN_EXTENTS,MAX_EXTENTS ,BLOCKS ,EMPTY_BLOCKS from user_tables where table_name in ('TEST4','TEST5','TEST6');



TABLE TABLESP PCT_FREE INITIAL_EXTENT NEXT_EXTENT MIN_EXTENTS MAX_EXTENTS BLOCKS EMPTY_BLOCKS

----- ------- ---------- -------------- ----------- ----------- ----------- ---------- ------------

TEST6 TEST6 10 2097152 2097152 1 2147483645 58 0


TEST5 TEST5 10 65536 1048576 1 2147483645 5 0


TEST4 TEST4 10 65536 1048576 1 2147483645 5 0



ZN@PROD>create table t66 (x int) tablespace test6 storage(initial 32k next 32k minextents 2);



Table created.



ZN@PROD>insert into t66 values(66);



1 row created.



ZN@PROD>commit;



Commit complete.




ZN@PROD>exec dbms_stats.gather_table_stats('ZN','T66');



ZN@PROD>select table_name, TABLESPACE_NAME , PCT_FREE ,INITIAL_EXTENT ,NEXT_EXTENT ,MIN_EXTENTS,MAX_EXTENTS ,BLOCKS ,EMPTY_BLOCKS from user_tables where table_name in ('T66');



TABLE TABLESP PCT_FREE INITIAL_EXTENT NEXT_EXTENT MIN_EXTENTS MAX_EXTENTS BLOCKS EMPTY_BLOCKS

----- ------- ---------- -------------- ----------- ----------- ----------- ---------- ------------

T66 TEST6 10 65536 32768 1 2147483645 58 0



-- 其实我们发现,上面所创建的一系列表空间和表,除了TEST6表的BLOCKS数量=58外,其他属性都还基本可以理解。从表T66可以看出,建表语句中指定的STORAGE会覆盖所在表空间的STORAGE属性。INITIAL_EXTENT的值等于STORAGE中指定的INITIAL*MINEXTENTS。



至于TEST6表的BLOCKS数量为什么=58,和之前的TEST4的26又有不同,可能与INITIAL参数的指定有关。


下面还可以继续做一个实验,修改表的INITIAL参数,看看BLOCKS有什么变化:




ZN@PROD>create table t666 (x int) tablespace test6 storage(initial 64k next 64k minextents 2);



Table created.




ZN@PROD>insert into t666 values(666);



1 row created.



ZN@PROD>commit;



Commit complete.



ZN@PROD>exec dbms_stats.gather_table_stats('ZN','T666');



PL/SQL procedure successfully completed.




ZN@PROD>select table_name, TABLESPACE_NAME , PCT_FREE ,INITIAL_EXTENT ,NEXT_EXTENT ,MIN_EXTENTS,MAX_EXTENTS ,BLOCKS ,EMPTY_BLOCKS from user_tables where table_name in ('T666');



TABLE TABLESP PCT_FREE INITIAL_EXTENT NEXT_EXTENT MIN_EXTENTS MAX_EXTENTS BLOCKS EMPTY_BLOCKS

----- ------- ---------- -------------- ----------- ----------- ----------- ---------- ------------

T666 TEST6 10 131072 65536 1 2147483645 58 0




-- 发现BLOCKS还是等于58. 说明BLOCS数量与表的STORAGE属性无关,与表空间的分配属性有关。




-- 再建两个表空间,一个的unifor size=512k,一个=1M,和表空间TEST3, TEST6做一个横向比较:




ZN@PROD>create tablespace test7 datafile '/s01/app/oracle/oradata/PROD/disk1/test7.dbf' size 10M uniform size 1M;



Tablespace created.



ZN@PROD>create tablespace test8 datafile '/s01/app/oracle/oradata/PROD/disk1/test8.dbf' size 10M uniform size 512k;



Tablespace created.




ZN@PROD>create table t777(X INT) tablespace test7;



Table created.



ZN@PROD>create table t888(X INT) tablespace test8;



Table created.



ZN@PROD>insert into t777 values(777);



1 row created.



ZN@PROD>commit;



Commit complete.



ZN@PROD>insert into t888 values(888);



1 row created.



ZN@PROD>commit;



Commit complete.



ZN@PROD>exec dbms_stats.gather_table_stats('ZN','T777');



PL/SQL procedure successfully completed.



ZN@PROD>exec dbms_stats.gather_table_stats('ZN','T888');



PL