ORACLE表空間管理方式segment和extent


  • 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.

  • 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 specify AUTOALLOCATE for a temporary tablespace.

  • UNIFORM specifies that the tablespace is managed with uniform extents of SIZE bytes.The default SIZE is 1 megabyte. All extents of temporary tablespaces are of uniform size, so this keyword is optional for a temporary tablespace. However, you must specify UNIFORM in order to specifySIZE. You cannot specify UNIFORM 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 DEFAULTstorage_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 effectsYou 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 PCTUSEDFREELIST, 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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM