- A permanent tablespace contains persistent schema objects. Objects in permanent tablespaces are stored in data files.
- An undo tablespace is a type of permanent tablespace used by Oracle Database to manage undo data if you are running your database in automatic undo management mode. Oracle strongly recommends that you use automatic undo management mode rather than using rollback segments for undo.
- A temporary tablespace contains schema objects only for the duration of a session. Objects in temporary tablespaces are stored in temp files.
1、extent_management_clause
The extent_management_clause
lets you specify how the extents of the tablespace will be managed.
Note:
After you have specified extent management with this clause, you can change extent management only by migrating the tablespace.
AUTOALLOCATE
specifies that the tablespace is system managed. Users cannot specify an extent size. You cannot specifyAUTOALLOCATE
for a temporary tablespace.UNIFORM
specifies that the tablespace is managed with uniform extents ofSIZE
bytes.The defaultSIZE
is 1 megabyte. All extents of temporary tablespaces are of uniform size, so this keyword is optional for a temporary tablespace. However, you must specifyUNIFORM
in order to specifySIZE
. You cannot specifyUNIFORM
for an undo tablespace.
If you do not specify AUTOALLOCATE
or UNIFORM
, then the default is UNIFORM
for temporary tablespaces and AUTOALLOCATE
for all other types of tablespaces.
If you do not specify the extent_management_clause
, then Oracle Database interprets the MINIMUM
EXTENT
clause and the DEFAULT
storage_clause
to determine extent management.
The DICTIONARY
keyword is deprecated. It is still supported for backward compatibility. However, Oracle recommends that you create locally managed tablespaces. Locally managed tablespaces are much more efficiently managed than dictionary-managed tablespaces. The creation of new dictionary-managed tablespaces is scheduled for desupport.
2、logging_clause
Specify the default logging attributes of all tables, indexes, materialized views, materialized view logs, and partitions within the tablespace. LOGGING
is the default. This clause is not valid for a temporary or undo tablespace.
The tablespace-level logging attribute can be overridden by logging specifications at the table, index, materialized view, materialized view log, and partition levels.
See Also:
logging_clause for a full description of this clause
FORCE LOGGING
Use this clause to put the tablespace into FORCE
LOGGING
mode. Oracle Database will log all changes to all objects in the tablespace except changes to temporary segments, overriding any NOLOGGING
setting for individual objects. The database must be open and in READ
WRITE
mode.
This setting does not exclude the NOLOGGING
attribute. You can specify both FORCE
LOGGING
and NOLOGGING
. In this case, NOLOGGING
is the default logging mode for objects subsequently created in the tablespace, but the database ignores this default as long as the tablespace or the database is inFORCE
LOGGING
mode. If you subsequently take the tablespace out of FORCE
LOGGING
mode, then the NOLOGGING
default is once again enforced.
Note:
FORCE
LOGGING
mode can have performance effects. You cannot specify FORCE
LOGGING
for an undo or temporary tablespace.
3、segment_management_clause
The segment_management_clause
is relevant only for permanent, locally managed tablespaces. It lets you specify whether Oracle Database should track the used and free space in the segments in the tablespace using free lists or bitmaps. This clause is not valid for a temporary tablespace.
AUTO Specify AUTO
if you want the database to manage the free space of segments in the tablespace using a bitmap. If you specify AUTO
, then the database ignores any specification for PCTUSED
, FREELIST
, and FREELIST
GROUPS
in subsequent storage specifications for objects in this tablespace. This setting is called automatic segment-space management and is the default.
MANUAL Specify MANUAL
if you want the database to manage the free space of segments in the tablespace using free lists. Oracle strongly recommends that you do not use this setting and that you create tablespaces with automatic segment-space management.
To determine the segment management of an existing tablespace, query the SEGMENT_SPACE_MANAGEMENT
column of the DBA_TABLESPACES
orUSER_TABLESPACES
data dictionary view.
Notes:
If you specify AUTO
segment management, then:
- If you set extent management to
LOCAL
UNIFORM
, then you must ensure that each extent contains at least 5 database blocks. - If you set extent management to
LOCAL
AUTOALLOCATE
, and if the database block size is 16K or greater, then Oracle manages segment space by creating extents with a minimum size of 5 blocks rounded up to 64K.
Restrictions on Automatic Segment-Space Management This clause is subject to the following restrictions:
- You can specify this clause only for a permanent, locally managed tablespace.
- You cannot specify this clause for the
SYSTEM
tablespace
=======================================================
extent--最小空间分配单位 --tablespace management
block --最小i/o单位 --segment management
create tablespace james
datafile ‘/export/home/oracle/oradata/james.dbf‘
size 100M --初始的文件大小
autoextend On --自动增长-默认为off
next 10M --每次自动增长大小
maxsize 2048M --最大文件大小
extent management local --表空间采用本地表空间管理 --默认就是local-system可不用指定。
uniform size 128k --uniform设置extent每次分配的大小统一为128k(如果是db_block_size=8k,则每次分配16个块)
--如果不指定大小,则为1M,即为1024/8个block
--autoallocate设置extent大小由系统自动分配
--不管系统大小分配为多少,但统一尺寸是64k(在bitmap中标记位的大小)。
--autoallocate在dba_extents中的allocation_type中显示为 SYSRTEM
segment space management auto; --默认就是auto
--segment中的block管理有两种:MSSM(Manual Segment Space Management),
ASSM(Auto Systemt Space Management)
--Auto 模式时只有pctfree参数起作用
--Manual 模式时freelist,pctfree,pctused参数起作用。
Tablespace 管理方式有两种:(管理extent)
1 数据字典空间管理 dictionary managed tablespace
通过管理两个主要的数据字典表,UET$(Used EXtends) 和FET$(Free EXtends)来实现
在9i以后已淘汰
缺点:1 并发访问争用
2 产生大量redo undo
3 空间碎片
2 本地表空间管理 Local managed tablespace
位图管理
数据文件头部加入位图区域
extent management local
具体空间分配方式:
1 autoallocate ----allocation_type=system
2 uniform ----allocation_type=uniform
ALLOCATION_TYPE 这个值有3个选项:
1、system:一旦设定该值,next_extent将为空,只有extents值。该值是默认值。这个选项的最小是64K
2、 user:一旦设定该值,就允许我们可以控制next_extent了。只有两种情况出现users:一是该ts是数据字典管理的;另外一个是该ts是从 数据字典管理转移到local的(用dbms_space_admin.tablespace_migrate_to_local)
3、uniform:将标明所有的extent的大小将一致,temp表空间只能采用这个方式;以上两个情况的extent的大小将不一致;uniform中的默认值为1M
Segment 管理方式有两种:(管理Block)
1 MSSM(Manual Segment Space Management)
2 ASSM(Auto Systemt Space Management)
1 MSSM(Manual Segment Space Management)
通过在segment的段头分配自由列表(freelist)来管理block
通过两个参数 pctfree pctused来管理block如何进出freelist
pctfree 值表示预留多少%的block空间用于更新
pctused 值表示低于这个值是,block会重新加入到freelist上
通过dba_tables,dba_indexes查看freelist,pctfree,pctused等参数的设置
2 ASSM(Auto Systemt Space Management)
通过在segment的段头分配位图(bitmap)来管理block
不再需要freelist
不在需要pctused,因为不需要从freelist上摘除block。
前面提到了数据文件上block1-2是数据头文件,block3-8是extent的位图。
block9-10是ASSM的block的一级和二级位图。
ASSM最大支持三级为图,但是一般非常难见到使用三级目录的
(段空间管理: 本地管理的表空间中的段空间管理方式可指定为:
自动:Oracle DB 使用位图管理段中的空闲空间.位图描述了段中每个数据块的状态,该状态与可插入行的块中的空间量有关.当数据块中可用空间增多或减少时,位图中会反映数据块的新状态.通过使用位图,Oracle DB 可以提高管理空闲空间的自动化程度.因此,这种空间管理方式称为"自动段空间管理(ASSM)".
手动:此方法指定要使用空闲列表来管理段中的空闲空间.空闲列表是由一些数据块组成的列表,这些数据块中有可插入行的空间.由于这种管理段空间的方式需要为在表空间中创建的方案对象指定并优化PCTUSED、FREELISTS和FREELIST GROUPS存储参数,因此这种方式称为"手动段空间管理".支持使用此方法是为了向后兼容,建议使用ASSM.)
查看分区和段空间管理方式:
SQL> select tablespace_name,extent_management,segment_space_management from dba_tablespaces;
TABLESPACE_NAME EXTENT_MANAGEMENT SEGMENT_SPACE_MANAGEMENT
------------------------------ ----------------- ------------------------
SYSTEM LOCAL MANUAL
SYSAUX LOCAL AUTO
UNDOTBS1 LOCAL MANUAL
TEMP LOCAL MANUAL
USERS LOCAL AUTO
EXAMPLE LOCAL AUTO
LXJ_TEMP LOCAL MANUAL
LXJ_DATA LOCAL AUTO
8 rows selected
===============
FROM:
http://www.cnblogs.com/blsong/archive/2009/11/09/1599076.html
http://docs.oracle.com/cd/E11882_01/server.112/e41084/statements_7003.htm#SQLRF01403