Locally vs. Dictionary Managed Tablespaces
整理自:http://www.orafaq.com/node/3.
When Oracleallocates space to a segment (like a table or index), a group of contiguousfree blocks, called an extent, is added to the segment. Metadata regardingextent allocation and unallocated extents are either stored in the datadictionary, or in the tablespace itself. Tablespaces that record extentallocation in the dictionary, are called dictionary managed tablespaces, andtablespaces that record extent allocation in the tablespace header, are calledlocally managed tablespaces.
表空间分配段空间,即区:一组连续的块。表空间关于区分配的信息被存于数据字典(DMT)或表空间自身(LMT)位图区
查看
数据库中表空间管理方式:
SQL> select tablespace_name,extent_management, allocation_type from dba_tablespaces;
TABLESPACE_NAME EXTENT_MAN ALLOCATIO
------------------------------ -------------------
SYSTEM DICTIONARY USER
SYS_UNDOTS LOCAL SYSTEM
TEMP LOCAL UNIFORM
DictionaryManaged Tablespaces (DMT):
Oracle use thedata dictionary (tables in the SYS schema) to track allocated and free extentsfor tablespaces that is in "dictionary managed" mode. Free space isrecorded in the SYS.FET$ table, and used space in the SYS.UET$ table. Wheneverspace is required in one of these tablespaces, the ST (space transaction)enqueue latch must be obtained to do inserts and deletes agianst these tables.As only one process can acquire the ST enque at a given time, this often leadto contention(竞争).
使用数据字典管理区分配。空闲空间被记录在SYS.FET$表中,已使用空间记录在SYS.UET$表。
Execute thefollowing statement to create a dictionary managed
tablespace: 创建数据字典管理表空间:
SQL> CREATE TABLESPACE ts1 DATAFILE'/oradata/ts1_01.dbf' SIZE 50M
EXTENT MANAGEMENT DICTIONARY
DEFAULT STORAGE ( INITIAL 50K NEXT 50KMINEXTENTS 2 MAXEXTENTS 50 PCTINCREASE 0);
Locally ManagedTablespaces (LMT):
Using LMT, eachtablespace manages it's own free and used space within a bitmap structurestored in one of the tablespace's data files. Each bit corresponds to adatabase block or group of blocks. Execute one of the following statements tocreate a locally managed
tablespace:
注意:在Oracle920中,默认系统表空间是local管理,因此不能在数据库中建立数据字典管理的表空间。
如果想要建立数据字典管理的表空间,必须在建立数据库时,将系统表空间改为数据字典管理才可以。
SQL> CREATE TABLESPACE ts2 DATAFILE'/oradata/ts2_01.dbf' SIZE 50M
EXTENT MANAGEMENT LOCAL AUTOALLOCATE;
SQL> CREATE TABLESPACE ts3 DATAFILE'/oradata/ts3_01.dbf' SIZE 50M
EXTENT MANAGEMENT LOCAL UNIFORM SIZE 128K;
Note the differencebetween AUTOALLOCATE and UNIFORM SIZE: 注意AUTOALLOCATE与UNIFORM SIZE选项区别!
AUTOALLOCATEspecifies that extent sizes are system managed. Oracle will choose"optimal" next extent sizes starting with 64KB. As the segment growslarger extent sizes will increase to 1MB, 8MB, and eventually to 64MB. This isthe recommended option for a low or unmanaged environment.
UNIFORMspecifies that the tablespace is managed with uniform extents of SIZE bytes(use K or M to specify the extent size in kilobytes or megabytes). The defaultsize is 1M. The uniform extent size of a locally managed tablespace cannot beoverridden when a schema object, such as a table or an index, is created.
Also not, if youspecify, LOCAL, you cannot specify DEFAULT STORAGE, MINIMUM EXTENT orTEMPORARY.
如果是本地管理表空间则不可以指定DEFAULT STORAGE与MINIMUM EXTENT或TEMPORARY选项。
Advantages ofLocally Managed Tablespaces: 本地管理优势:
Eliminates the need for recursive SQL operations against the data dictionary (UET$ and FET$ tables) 消除对于数据字典表的递归SQL操作。
Reduce contention on data dictionary tabl |