遭遇oracle表空文件大小限制

先說一個結果吧。對於數據塊大小是8K的數據庫,單個數據文件大小的限制是小於32G,不是小於等於32G。

看看轉過來的文章:

——————————————————————————————————

ORACLE的一個數據文件的最大值是多少呢?

我們知道ORACLE的最小的物理單位是BLOCK,數據文件的組成的最終形式也是block,那麼數據文件的大小限制就應該是block數量的限制,那麼究竟block的數量有何限制,這裏就要提到一個ORACLE內部術語DBA(此dba非數據庫管理員,而是data block address)

   Extent 0     :  L1 dba:  0x01800009 Data dba:  0x0180000d
   Extent 1     :  L1 dba:  0x01800089 Data dba:  0x0180008b
   Extent 2     :  L1 dba:  0x01800109 Data dba:  0x0180010b
   Extent 3     :  L1 dba:  0x01800189 Data dba:  0x0180018b
   Extent 4     :  L1 dba:  0x01800209 Data dba:  0x0180020b
   Extent 5     :  L1 dba:  0x01800289 Data dba:  0x0180028b

dba是以16進製表示的(因爲有0X),注意看一共用了8爲的16進制,換算成二進制就是32bit,而其中DBA又用10位來記錄file_id,22bit來記錄block_id,那麼在一個數據文件中最多能夠記錄2^22個block,如果一個block_size=8k,那麼這個數據文件的最大值就是8K*2^22,也就是32G,所以數據文件的最大值應該取決於塊大小,而oracle塊最大值是32K,也就是32G*4=128G。

SQL> select power(2,22)*8/1024/1024 from dual;

POWER(2,22)*8/1024/1024
-----------------------
                     32

————————————————————————————————————————

上原文地址:http://blog.csdn.net/robinson1988/article/details/5073908

轉載這個文章的原因是我今天建表空失敗了。當時想當然的認爲AIX是64位小機,數據庫也是64位的數據庫,單個表空文應該不止32G,也是保守見單個表空文件我設置大小爲32768MB,結果報錯:ORA-01144: File size (4194304 blocks) exceeds maximum of 4194303 blocks。頭痛啊,不明白啊。32768MB不就是32G嗎?我都沒超過這個限制,還64位操作系統,64位數據庫呢!於是上網查到了上面這個文章,查完後更不理解了,這明明沒超過32G怎麼就不讓我建?再查,查到了下面這段文字:

————————————————————————————————————————————

Oracle has limitation boundaries related with the db_block_size. 
Depending the db_block_size you can create datafiles up to one specific size. For example:
db_block_size | Datafile upper limit
----------------------------------------------
2kb               8GB
4kb              16GB
8kb              32GB
16kb             64GB
32kb             128GB
If you have db_block_size=8Kb and try to create a datafile with size 33GB you will get the error:
ORA-01144: File size (4224000 blocks) exceeds maximum of 4194303 blocks
The formula to calculate the max size is: db_block_size * 4194303. 

The workaround to this situation is obvious. One simple solution is to create multiple datafiles with smaller size. The othe is to use Bigfile tablespaces 

Bigfile tablespaces 
This is a feature of Oracle 10g. A bigfile tablespace contains only one datafile (or tempfile) which can be as big as 2^32 (=4GB) blocks.
create bigfile tablespace beeeg_ts data file '/o1/dat/beeeg.dbf' size 2T;
Bigfile tablespaces are supported only for locally managed tablespaces with automatic segment-space management (which is the default setting since Oracle 9i). There are two exceptions: locally managed undo and temporary tablespaces can be bigfile tablespaces, even though their segments are manually managed. 

The system and sysaux tablespace cannot be created as bigfile tablespace. Bigfile tablespaces should be used with automatic storage management, or other logical volume managers that support dynamically extensible logical volumes, striping and RAID.

——————————————————————————————————————————————

第一段的大意是:單個文件大小的計算公式是:db_block_size * 4194303,如果數據塊大小是8K,則單個表空文件最大是:8K*4194303=34359730176字節,換算成MB即32767.9921875MB,而32768MB是34359738368字節,所以對於數據塊大小是8K的數據庫而言,單個表空文件大小是的限制是小於32G而不是小於等於32G。終於明白爲什麼我想建32G的表空文件不能成功了,建32767MB的表空就可以了,修改腳本大小後成功建立表空。

Bigfile tablespaces 那段的大意是從oracle 10G開始支持一種叫大文件表空的東西,最多可以支持有2^32個數據塊的表空文件。除undo和temporary表空之外,其它表空必須是開啓automatic segment-space management才能使用大文件表空。但建表空的語法不同了,多了個關鍵字“bigfile”。由於我也不想用這種特性,就不細研究了。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章