关于Oracle10g中tempfile 空间分配的问题:temp file will not actually allocate disk space

本文介绍Oracle10g中临时表空间(temp tablespace)的特性,特别是其延迟分配磁盘空间的行为,并提供一种方法来预先分配磁盘空间以避免运行时可能遇到的问题。
CREATE TEMPORARY TABLESPACE temp
TEMPFILE 'C:ORACLEORADATAORA10TEMP01.DBF' SIZE 2G ;


Temporary tablespaces are created using temp files instead of datafiles. Temp files are allocated slightly differently than datafiles. Although atafiles are completely allocated and initialized at creation time, temp files are not always guaranteed to allocate the disk space specified.
[@more@]




This means that on some Unix systems a temp file will not actually allocate disk space until a sorting operation requires it. Although this delayed allocation approach allows rapid file creation, it can cause problems down the road if you ave not reserved the space that may be needed at runtime.




可以通过一个方法改变:


Workaround for Deferred Temp File Disk Space Allocations

A workaround for allocating temp file space at runtime is to preallocate it, just like you do with a datafile. In fact, you first allocate it as a datafile and then drop the tablespace, leaving the file. Finally, you create your temp tablespace reusing the old datafile as a temp file.


-- first create it as a permanent tablespace
-- to force the disk space to be allocated
CREATE TABLESPACE temp
DATAFILE '/ORADATA/PROD/TEMP01.DBF' SIZE 2G;

-- dropping the tablespace does not remove
-- the file from the file system
DROP TABLESPACE temp;

-- the keyword REUSE is needed to use the existing
-- file created in the previous steps
CREATE TEMPORARY TABLESPACE temp
TEMPFILE '/ORADATA/PROD/TEMP01.DBF' SIZE 2G REUSE


原来在建立Oracle10g资料库的时候,temp表空间虽然分配了2G大小的一个文件TEMP01.DBF , 但是没有Sorting等动作之前,temp01.dbf 文件是不占用磁盘空间的 。只有当sorting, create index , hash join 等用到temp动作的时候才会真正开始占用分配磁盘空间 。占用磁盘空间之后不会释放(当然里面的数据会释放) 。

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/35489/viewspace-921341/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/35489/viewspace-921341/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值