遭遇oracle表空文件大小限制

来源:互联网 发布:java工程师专业技能 编辑:程序博客网 时间:2024/06/07 03:49

先说一个结果吧。对于数据块大小是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”。由于我也不想用这种特性,就不细研究了。