创建一个本地管理的表空间之AUTOALLOCATE和UNIFORM

官方文档解释:

Create a locally managed tablespace by specifying LOCAL in the EXTENT MANAGEMENT clause of the CREATE TABLESPACE statement. This is the default for new permanent tablespaces, but you must specify the EXTENT MANAGEMENT LOCAL clause to specify either the AUTOALLOCATE clause or the UNIFORM clause. You can have the database manage extents for you automatically with the AUTOALLOCATE clause (the default), or you can specify that the tablespace is managed with uniform extents of a specific size (UNIFORM).

If you expect the tablespace to contain objects of varying sizes requiring many extents with different extent sizes, then AUTOALLOCATE is the best choice. AUTOALLOCATE is also a good choice if it is not important for you to have a lot of control over space allocation and deallocation, because it simplifies tablespace management. Some space may be wasted with this setting, but the benefit of having Oracle Database manage your space most likely outweighs this drawback.

If you want exact control over unused space, and you can predict exactly the space to be allocated for an object or objects and the number and size of extents, then UNIFORMis a good choice. This setting ensures that you will never have unusable space in your tablespace.

When you do not explicitly specify the type of extent management, Oracle Database determines extent management as follows:

  • If the CREATE TABLESPACE statement omits the DEFAULT storage clause, then the database creates a locally managed autoallocated tablespace.

  • If the CREATE TABLESPACE statement includes a DEFAULT storage clause, then the database considers the following:

    • If you specified the MINIMUM EXTENT clause, the database evaluates whether the values of MINIMUM EXTENTINITIAL, and NEXT are equal and the value of PCTINCREASE is 0. If so, the database creates a locally managed uniform tablespace with extent size = INITIAL. If the MINIMUM EXTENTINITIAL, and NEXTparameters are not equal, or if PCTINCREASE is not 0, the database ignores any extent storage parameters you may specify and creates a locally managed, autoallocated tablespace.

    • If you did not specify MINIMUM EXTENT clause, the database evaluates only whether the storage values of INITIAL and NEXT are equal and PCTINCREASE is 0. If so, the tablespace is locally managed and uniform. Otherwise, the tablespace is locally managed and autoallocated.

The following statement creates a locally managed tablespace named lmtbsb and specifies AUTOALLOCATE:

CREATE TABLESPACE lmtbsb DATAFILE '/u02/oracle/data/lmtbsb01.dbf' SIZE 50M
    EXTENT MANAGEMENT LOCAL AUTOALLOCATE;

AUTOALLOCATE causes the tablespace to be system managed with a minimum extent size of 64K.

The alternative to AUTOALLOCATE is UNIFORM. which specifies that the tablespace is managed with extents of uniform size. You can specify that size in the SIZE clause of UNIFORM. If you omit SIZE, then the default size is 1M.

The following example creates a tablespace with uniform 128K extents. (In a database with 2K blocks, each extent would be equivalent to 64 database blocks). Each 128K extent is represented by a bit in the extent bitmap for this file.

CREATE TABLESPACE lmtbsb DATAFILE '/u02/oracle/data/lmtbsb01.dbf' SIZE 50M
    EXTENT MANAGEMENT LOCAL UNIFORM SIZE 128K;

You cannot specify the DEFAULT storage clause, MINIMUM EXTENT, or TEMPORARY when you explicitly specify EXTENT MANAGEMENT LOCAL. To create a temporary locally managed tablespace, use the CREATE TEMPORARY TABLESPACE statement.

Note:

When you allocate a data file for a locally managed tablespace, you should allow space for metadata used for space management (the extent bitmap or space header segment) which are part of user space. For example, if you specify the  UNIFORM clause in the extent management clause but you omit the  SIZE parameter, then the default extent size is 1MB. In that case, the size specified for the data file must be larger (at least one block plus space for the bitmap) than 1MB.
翻译:

LOCAL语句EXTENT MANAGEMENT子句中指定来创建本地管理的表空间CREATE TABLESPACE这是新永久表空间的默认值,但是您必须指定EXTENT MANAGEMENTLOCAL子句来指定AUTOALLOCATE子句或UNIFORM子句。您可以让数据库自动使用AUTOALLOCATE子句(缺省值)管理扩展数据块,也可以指定使用特定大小的统一扩展数据块来管理表空间(UNIFORM)。

如果您希望表空间包含具有不同大小的不同大小的对象,那么这AUTOALLOCATE是最好的选择。AUTOALLOCATE如果对空间分配和释放有很大的控制并不重要,那么也是一个不错的选择,因为它简化了表空间管理。使用此设置可能会浪费一些空间,但使用Oracle数据库管理空间的好处很可能大于此缺点。

如果要精确控制未使用的空间,并且可以准确预测要为一个或多个对象分配的空间以及扩展的数量和大小,那么这UNIFORM是一个不错的选择。此设置可确保您的表空间永远不会有无法使用的空间。

如果不明确指定扩展区管理的类型,Oracle数据库将按如下方式确定扩展区管理:

  • 如果CREATE TABLESPACE语句省略了DEFAULT存储子句,则数据库将创建一个本地托管的自动分配的表空间。

  • 如果CREATE TABLESPACE语句包含DEFAULT存储子句,则数据库会考虑以下内容:

    • 如果指定的MINIMUM EXTENT子句,则数据库评估是否的值MINIMUM EXTENTINITIALNEXT是相等的和的值PCTINCREASE是0。如果是这样,数据库中创建一个本地管理的统一表空间的范围大小= INITIAL如果MINIMUM EXTENTINITIALNEXT参数不相等,或者如果PCTINCREASE不为0,数据库忽略您可以指定任何程度的存储参数,并创建一个本地管理,autoallocated表空间。

    • 如果没有指定MINIMUM EXTENT子句,则数据库只评估INITIAL的存储值NEXT是否等于PCTINCREASE0.如果是,表空间是本地管理和统一的。否则,表空间是本地管理和自动分配的。

以下语句创建一个名为lmtbsb并指定的本地管理表空间AUTOALLOCATE

CREATE TABLESPACE lmtbsb DATAFILE'/u02/oracle/data/lmtbsb01.dbf'SIZE 50M 
    EXTENT MANAGEMENT LOCAL AUTOALLOCATE;

AUTOALLOCATE 使表空间以64K的最小范围大小进行系统管理。

替代方法AUTOALLOCATEUNIFORM它指定表空间是用统一大小的范围来管理的。你可以在SIZE子句中指定这个大小UNIFORM如果省略SIZE,则默认大小为1M。

以下示例将创建一个具有统一的128K范围的表空间。(在具有2K块的数据库中,每个范围将相当于64个数据库块)。每个128K的范围在这个文件的范围位图中用一个位表示。

CREATE TABLESPACE lmtbsb DATAFILE'/u02/oracle/data/lmtbsb01.dbf'SIZE 50M 
    EXTENT MANAGEMENT LOCAL UNIFORM SIZE 128K;

您不能指定DEFAULT存储子句MINIMUM EXTENT,或者TEMPORARY当您明确指定EXTENT MANAGEMENT LOCAL要创建一个临时的本地管理表空间,请使用该CREATE TEMPORARY TABLESPACE语句。

注意:

为本地管理的表空间分配数据文件时,应该允许用于空间管理的元数据空间(扩展位图或空间标题段),它们是用户空间的一部分。例如,如果您 UNIFORM 在扩展区管理子句中指定了子句,但是省略了该 SIZE 参数,则默认扩展区大小为1MB。在这种情况下,为数据文件指定的大小必须比1MB大(至少一个块加上位图的空间)。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值