Oracle資料檔案自動擴充套件會充分利用最後剩餘空間

cow977發表於2011-12-09

SQL Server資料庫檔案,自動擴充套件時最後剩餘空間如果不滿足擴充套件條件,系統不會自動再利用剩餘容量,http://space.itpub.net/81227/viewspace-713277

 

以下測試在Oracle中是否也存在同樣的問題。

 

SQL> conn / as sysdba

SQL> select * from v$version;

 

BANNER

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

Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production

 

--建立一個初始10M,每次擴充套件30M,最大60M的表空間

SQL> create tablespace t_demo datafile '/home/oracle/oradata/zw/t_demo01.dbf' size 10M autoextend on next 30M maxsize 60M;

 

Tablespace created.

 

SQL> create table t_table as select * from dba_objects;

 

Table created.

 

SQL> alter table t_table move tablespace t_demo;

 

Table altered.

 

SQL> select FILE#,name ,BYTES ,BLOCKS,CREATE_BYTES,BLOCK_SIZE from v$datafile where file#=6;

 

     FILE# NAME              BYTES     BLOCKS CREATE_BYTES BLOCK_SIZE

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

         6 t_demo01.dbf  10485760       1280     10485760       8192

 

SQL> insert into t_table select * from t_table;

 

72339 rows created.

 

SQL> select FILE#,name ,BYTES ,BLOCKS,CREATE_BYTES,BLOCK_SIZE from v$datafile where file#=6;

 

     FILE# NAME              BYTES     BLOCKS CREATE_BYTES BLOCK_SIZE

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

         6 t_demo01.dbf   41943040       5120     10485760       8192

--此處擴充套件了30M,總容量為40M

 

SQL> insert into t_table select * from t_table;

 

144678 rows created.

 

SQL> select FILE#,name ,BYTES ,BLOCKS,CREATE_BYTES,BLOCK_SIZE from v$datafile where file#=6;

 

     FILE# NAME              BYTES     BLOCKS CREATE_BYTES BLOCK_SIZE

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

         6 t_demo01.dbf   41943040       5120     10485760       8192

 

SQL> select segment_name,bytes from dba_segments where segment_name='T_TABLE';

 

SEGMENT_NAME     BYTES

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

T_TABLE            34603008

 

SQL> insert into t_table select * from t_table;

insert into t_table select * from t_table

*

ERROR at line 1:

ORA-01653: unable to extend table SYS.T_TABLE by 128 in tablespace T_DEMO

 

SQL> select segment_name,bytes from dba_segments where segment_name='T_TABLE';

 

SEGMENT_NAME     BYTES

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

T_TABLE            61865984

 

SQL> select FILE#,name ,BYTES ,BLOCKS,CREATE_BYTES,BLOCK_SIZE from v$datafile where file#=6;

 

     FILE# NAME              BYTES     BLOCKS CREATE_BYTES BLOCK_SIZE

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

         6 t_demo01.dbf   62914560       7680     10485760       8192

--此處擴充套件了20M,總容量為60M

 

SQL> select 7680*8/1024 from dual;

7680*8/1024

-----------

         60

 

Oracle中,資料檔案自動擴充套件,最後會充分利用剩餘的可用空間,使資料檔案大小達到設定的最大容量。

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/81227/viewspace-713286/,如需轉載,請註明出處,否則將追究法律責任。

相關文章