1. 程式人生 > >Oracle表空間資料檔案大小設定

Oracle表空間資料檔案大小設定

Oracle資料檔案預設大小上限是32G,如果要資料檔案大於32G,需要在資料庫建立之初就設定好。

    表空間資料檔案容量與DB_BLOCK_SIZE有關,在初始建庫時,DB_BLOCK_SIZE要根據實際需要,設定為 4K,8K、16K、32K、64K等幾種大小,ORACLE的物理檔案最大隻允許4194304個數據塊(由作業系統決定),表空間資料檔案的最大值為 4194304×DB_BLOCK_SIZE/1024M。即:    4k最大表空間為:16384M=16G    8K最大表空間為:32768M=32G    16k最大表空間為:65536M=64G    32K最大表空間為:131072M=128G    64k最大表空間為:262144M=256G

在windows下只能使用2K,4K,8K,16K的塊大小,在文件

Oracle Database Administrator's Guide
10g Release 2 (10.2)
Part Number B14231-02

/B19306_01/server.102/b14231/create.htm#sthref372中有如下描述:

Tablespaces of nonstandard block sizes can be created using the CREATE TABLESPACE statement and specifying the BLOCKSIZE clause. These nonstandard block sizes can have any of the following power-of-two values: 2K, 4K, 8K, 16K or 32K. Platform-specific restrictions regarding the maximum block size apply, so some of these sizes may not be allowed on some platforms.

To use nonstandard block sizes, you must configure subcaches within the buffer cache area of the SGA memory for all of the nonstandard block sizes that you intend to use. The initialization parameters used for configuring these subcaches are described in the next section, "Managing the System Global Area (SGA)".

前一段說明了某些塊大小在某些平臺上是不可用的,具體情況受作業系統限制。比如windows下就有塊大小2048位元組到16384位元組的限制,不管是非標準塊還是標準塊。據http://www.ningoo.net/html/2007/can_not_use_32k_block_size_on_windows.html的說明,如果Windows下使用32K作為db_block_size建立資料庫,會報ORA-00374錯誤。

後一段說明使用非標準塊要設定相應的記憶體引數。

    Oracle是SGA自動共享記憶體管理,初始化引數db_4k_cache_size=0、db_8k_cache_size=0、db_16k_cache_size=0、

db_32k_cache_size = 0db_64k_cache_size = 0,使用
 如果要建立表空間並指定其檔案大小(由建立表空間的BLOCK_SIZE決定),需重新設定db_4k_cache_size、db_8k_cache_size、db_16k_cache_size、db_32k_cache_size、db_64k_cache_size的值。

 db_4k_cache_size:

 alter system set db_4k_cache_size = 4M scope=both; db_8k_cache_size:
 alter system set db_8k_cache_size = 8M scope=both;

 db_16k_cache_size:

 alter system set db_16k_cache_size = 16M scope=both;
 db_32k_cache_size:
 alter system set db_32k_cache_size = 32M scope=both; db_64k_cache_size:
 alter system set db_64k_cache_size = 64M scope=both;

其中windows系統只支援4k、8k、16k的設定。

設定好上述引數的值後,建立表空間:

CREATE TABLESPACE TEST DATAFILE 'E:\TEST.DBF'
SIZE 60G
AUTOEXTEND ON
BLOCKSIZE 16K
EXTENT MANAGEMENT LOCAL UNIFORM SIZE 2M
SEGMENT SPACE MANAGEMENT AUTO;

SIZE:資料檔案大小,不能超過BLOCKSIZE 16k(對應db_16k_cache_size)的大小16M*4194304/1024M=65536M=64G的值。