官方文档解释:
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 UNIFORM
is 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 theDEFAULT
storage clause, then the database creates a locally managed autoallocated tablespace. -
If the
CREATE TABLESPACE
statement includes aDEFAULT
storage clause, then the database considers the following:-
If you specified the
MINIMUM EXTENT
clause, the database evaluates whether the values ofMINIMUM EXTENT
,INITIAL
, andNEXT
are equal and the value ofPCTINCREASE
is 0. If so, the database creates a locally managed uniform tablespace with extent size =INITIAL
. If theMINIMUM EXTENT
,INITIAL
, andNEXT
parameters are not equal, or ifPCTINCREASE
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 ofINITIAL
andNEXT
are equal andPCTINCREASE
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 theUNIFORM
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
MANAGEMENT
LOCAL
子句来指定AUTOALLOCATE
子句或UNIFORM
子句。您可以让数据库自动使用AUTOALLOCATE
子句(缺省值)管理扩展数据块,也可以指定使用特定大小的统一扩展数据块来管理表空间(UNIFORM
)。
如果您希望表空间包含具有不同大小的不同大小的对象,那么这AUTOALLOCATE
是最好的选择。AUTOALLOCATE
如果对空间分配和释放有很大的控制并不重要,那么也是一个不错的选择,因为它简化了表空间管理。使用此设置可能会浪费一些空间,但使用Oracle数据库管理空间的好处很可能大于此缺点。
如果要精确控制未使用的空间,并且可以准确预测要为一个或多个对象分配的空间以及扩展的数量和大小,那么这UNIFORM
是一个不错的选择。此设置可确保您的表空间永远不会有无法使用的空间。
如果不明确指定扩展区管理的类型,Oracle数据库将按如下方式确定扩展区管理:
-
如果
CREATE TABLESPACE
语句省略了DEFAULT
存储子句,则数据库将创建一个本地托管的自动分配的表空间。 -
如果
CREATE TABLESPACE
语句包含DEFAULT
存储子句,则数据库会考虑以下内容:-
如果指定的
MINIMUM EXTENT
子句,则数据库评估是否的值MINIMUM EXTENT
,INITIAL
和NEXT
是相等的和的值PCTINCREASE
是0。如果是这样,数据库中创建一个本地管理的统一表空间的范围大小=INITIAL
。如果MINIMUM EXTENT
,INITIAL
和NEXT
参数不相等,或者如果PCTINCREASE
不为0,数据库忽略您可以指定任何程度的存储参数,并创建一个本地管理,autoallocated表空间。 -
如果没有指定
MINIMUM EXTENT
子句,则数据库只评估INITIAL
和的存储值NEXT
是否等于PCTINCREASE
0.如果是,表空间是本地管理和统一的。否则,表空间是本地管理和自动分配的。
-
以下语句创建一个名为lmtbsb
并指定的本地管理表空间AUTOALLOCATE
:
CREATE TABLESPACE lmtbsb DATAFILE'/u02/oracle/data/lmtbsb01.dbf'SIZE 50M EXTENT MANAGEMENT LOCAL AUTOALLOCATE;
AUTOALLOCATE
使表空间以64K的最小范围大小进行系统管理。
替代方法AUTOALLOCATE
是UNIFORM
。它指定表空间是用统一大小的范围来管理的。你可以在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大(至少一个块加上位图的空间)。