Oracle-Segment space management
按照預設條件建立表空間的時候,其實已經是segment space management已經auto了:
------------------------------------------------------------------------------------------ ------------------
SYSTEM MANUAL
UNDOTBS1 MANUAL
SYSAUX AUTO
TEMP MANUAL
USERS AUTO
EXAMPLE AUTO
INDX AUTO
LYONTBS AUTO
PERFSTAT AUTO
TTBS001 AUTO
Automatic Segment Space Management October 16, 2003 |
Automatic segment-space management is a simpler and more efficient way of managing space within a segment. It completely eliminates any need to specify and tune the pctused, freelists, and freelist groups storage parameters for schema objects created in the tablespace. If any of these attributes are specified, they are ignored. When you create a locally managed tablespace using the create TABLESPACE statement, the SEGMENT SPACE MANAGEMENT clause lets you specify how free and used space within a segment is to be managed. For example, the following statement creates tablespace mytbs1 with automatic segment-space management: CREATE TABLESPACE mytbs1 When an object such as a table or index is created using the locally managed tablespace, with automatic segment-space management enabled, there is no need to specify the pctfree or freelists. The in-segment free/used space is tracked using bitmaps as opposed to the free lists. When you cannot use the locally managed tablespace, and therefore the automatic management space feature, you have to depend on the traditional method of managing free lists and free lists groups. Automatic segment-space management offers the following benefits:
However, note that this automatic feature of segment space management is available only with locally managed tablespaces and their objects. A new column called SEGMENT_SPACE_MANAGEMENT has been added to the dba_tablespaces view to indicate the segment space management mode used by a tablespace. Use the Oracle procedure dbms_space.space_usage to provide the space usage ratio within each block in the Bitmap Managed Block (BMB) segments. It provides information regarding the number of blocks in a segment with the following range of free space. 0-25% free space within a block RAC Related AdvantagesThe performance and manageability gains provided by the automatic segment space management feature are particularly noticeable in a Real Application Cluster environment. It eliminates the need to alter the number of freelists and freelist groups when new instances are brought online, thereby saving the downtime associated with such table reorganizations. It also avoids the tuning effort previously required for multiple instance environments. An Oracle internal benchmark comparing the performance of automatic and manual segment space management, conducted on a two node Real Application Cluster database by inserting about 3 million rows in a table, showed that automatic segment space management provided a 35% performance gain over an optimally tuned segment (8 freelist groups, 20 freelists) using the manual mode. (For more details, refer to Oracle Metalink Note 180608.1) Use the new dbms_space.space_usage procedure for reporting the space position in BMB segments. This procedure provides the space usage ratio within each block. It is preferred over the dbms_space.free_blocks procedure. Let us look at an example (a SQL Block) of how to get information about the blocks: block_count.sql It yields the following output: Unformatted Blocks = 0 Where:
另外參考: |
#指定區尺寸為128k,如不指定,區尺寸預設為64k
CREATE TEMPORARY TABLESPACE temp_data TEMPFILE 'D:\oracle\ora92\oradata\db\TEMP_DATA.dbf' SIZE100M
CREATE USER peter IDENTIFIED BY peter
DEFAULT TABLESPACE data01 TEMPORARY TABLESPACE temp_data;
grant connect,resource,dba to peter;
一、建立表空間
CREATE TABLESPACE data01
DATAFILE '/oracle/oradata/db/DATA01.dbf' SIZE 500M
UNIFORM. SIZE128k; #指定區尺寸為128k,如不指定,區尺寸預設為64k
二、建立UNDO表空間
CREATE UNDO TABLESPACE UNDOTBS02
DATAFILE '/oracle/oradata/db/UNDOTBS02.dbf' SIZE 50M
#注意:在OPEN狀態下某些時刻只能用一個UNDO表空間,如果要用新建的表空間,必須切換到該表空間:
ALTER SYSTEM SET undo_tablespace=UNDOTBS02;
三、建立臨時表空間
CREATE TEMPORARY TABLESPACE temp_data
TEMPFILE '/oracle/oradata/db/TEMP_DATA.dbf' SIZE 50M
四、改變表空間狀態
1.使表空間離線
ALTER TABLESPACE game OFFLINE;
如果是意外刪除了資料檔案,則必須帶有RECOVER選項
ALTER TABLESPACE game OFFLINE FOR RECOVER;
2.使表空間聯機
ALTER TABLESPACE game ONLINE;
3.使資料檔案離線
ALTER DATABASE DATAFILE 3 OFFLINE;
4.使資料檔案聯機
ALTER DATABASE DATAFILE 3 ONLINE;
5.使表空間只讀
ALTER TABLESPACE game READ ONLY;
6.使表空間可讀寫
ALTER TABLESPACE game READ WRITE;
五、刪除表空間
DROP TABLESPACE data01 INCLUDING CONTENTS AND DATAFILES;
六、擴充套件表空間
首先檢視錶空間的名字和所屬檔案
select tablespace_name, file_id, file_name,
round(bytes/(1024*1024),0) total_space
from dba_data_files
order by tablespace_name;
1.增加資料檔案
ALTER TABLESPACE game
ADD DATAFILE '/oracle/oradata/db/GAME02.dbf' SIZE 1000M;
2.手動增加資料檔案尺寸
ALTER DATABASE DATAFILE '/oracle/oradata/db/GAME.dbf'
RESIZE 4000M;
3.設定資料檔案自動擴充套件
ALTER DATABASE DATAFILE '/oracle/oradata/db/GAME.dbf
AUTOEXTEND ON NEXT 100M
MAXSIZE 10000M;
設定後檢視錶空間資訊
SELECT A.TABLESPACE_NAME,A.BYTES TOTAL,B.BYTES USED, C.BYTES FREE,
(B.BYTES*100)/A.BYTES "% USED",(C.BYTES*100)/A.BYTES "% FREE"
FROM SYS.SM$TS_AVAIL A,SYS.SM$TS_USED B,SYS.SM$TS_FREE C
WHERE A.TABLESPACE_NAME=B.TABLESPACE_NAME AND A.TABLESPACE_NAME=C.TABLESPACE_NAME;
-----------------------------------------------------------------------------------------------------------------------------------
CREATE TABLESPACE命令
CREATE [UNDO] TABLESPACE tablespace_name
[DATAFILE datefile_spec1 [,datefile_spec2] ......
[ {MININUM EXTENT integer [k|m] | BLOCKSIZE integer [k] |logging clause|FORCE LOGGING |DEFAULT{data_segment_compression } storage_clause
|[online|offline]|[PERMANENT|TEMPORARY]|extent_manager_clause|segment_manager_clause}]
1、undo
說明系統將建立一個回滾表空間。
在9i中資料庫管理員可以不必管理回滾段,只有建立了undo表空間,系統就會自動管理回滾段的分配,回收的工作。當然,也可以建立一般的表空間,在上面建立回滾段.不過對於使用者來說,系統管理比自己管理要好很多.如果需要自己管理,請參見回滾段管理的命令詳解.
當沒有為系統指定回滾表空間時,系統將使用system系統回滾段來進行事務管理。
2、tablespace
指出表空間的名稱。
3、datafile datefile_spec1
指出表空間包含什麼空間檔案。datefile_spec1 是形如 ['filename'][SIZEinteger [ K|M]] [REUSE][autoextend_clause]
[autoextend_clause]切穩紓?AUTOEXTEND{OFF| ON[ NEXTinteger [ K| M] ][maxsize_clause] }
其中filename是資料檔案的全路徑名,size是檔案的大小,REUSE表示檔案是否被重用.
AUTOEXTEND表明是否自動擴充套件. OFF|ON表示自動擴充套件是否被關閉.NEXT表示資料檔案滿了以後,擴充套件的大小.
maxsize_clause表示資料檔案的最大大小.形如MAXSIZE{UNLIMITED| integer [ K|M] }.UNLIMITED表示無限的表空間.integer是資料檔案的最大大小.
4、MININUM EXTENT integer [k|m]
指出在表空間中範圍的最小值。這個引數可以減小空間碎片,保證在表空間的範圍是這個數值的整數倍。
5、BLOCKSIZE integer [k]
這個引數可以設定一個不標準的塊的大小。如果要設定這個引數,必須設定db_block_size,至少一個db_nk_block_size,並且宣告的integer的值必須等於db_nk_block_size.
注意:在臨時表空間不能設定這個引數。
6、logging clause
這個子句宣告這個表空間上所有的使用者物件的日誌屬性(預設是logging),包括表,索引,分割槽,物化檢視,物化檢視上的索引,分割槽。
7、FORCE LOGGING
使用這個子句指出表空間進入強制日誌模式。此時,系統將記錄表空間上物件的所有改變,除了臨時段的改變。這個引數高於物件的nologging選項。
注意:設定這個引數資料庫不行open並且出於讀寫模式。而且,在臨時表空間和回滾表空間中不能使用這個選項。
8、DEFAULT storage_clause
宣告預設的儲存子句。
9、online|offline
改變表空間的狀態。online使表空間建立後立即有效.這是預設值.offline使表空間建立後無效.這個值,可以從dba_tablespace中得到。
10、PERMANENT|TEMPORARY
指出表空間的屬性,是永久表空間還是臨時表空間。永久表空間存放的是永久物件,臨時表空間存放的是session生命期中存在的臨時物件。這個引數生成的臨時表空間建立後一直都是字典管理,不能使用extent management local選項。如果要建立本地管理表空間,必須使用create temporary tablespace
注意,宣告瞭這個引數後,不能宣告block size
11、extent_management_clause
這是最重要的子句,說明了表空間如何管理範圍。一旦你宣告瞭這個子句,只能透過移植的方式改變這些引數。
如果希望表空間本地管理的話,宣告local選項。本地管理表空間是透過點陣圖管理的。autoallocate說明表空間自動分配範圍,使用者不能指定範圍的大小。只有9.0以上的版本具有這個功能。uniform說明表空間的範圍的固定大小,預設是1m。
不能將本地管理的資料庫的system表空間設定成字典管理。
oracle公司推薦使用本地管理表空間。
如果沒有設定extent_management_clause,oracle會給他設定一個預設值。如果初始化引數compatible小於9.0.0,那麼系統建立字典管理表空間。如果大於9.0.0,那麼按照如下設定:
如果沒有指定default storage_clause,oracle建立一個自動分配的本地管理表空間。
否則,如果指定了mininum extent,那麼oracle判斷mininum extent、initial、next是否相等,以及pctincrease是否=0.如果滿足以上的條件,oracle建立一個本地管理表空間,extent size是initial.如果不滿足以上條件,那麼oracle將建立一個自動分配的本地管理表空間。
如果沒有指定mininum extent。initial、那麼oracle判斷next是否相等,以及pctincrease是否=0。如果滿足oracle建立一個本地管理表空間並指定uniform。否則oracle將建立一個自動分配的本地管理表空間。
注意:本地管理表空間只能儲存永久物件。如果你宣告瞭local,將不能宣告default storage_clause,mininum extent、temporary.
12、segment_management_clause
建立表空間
CREATE TABLESPACE data01
DATAFILE '/oracle/oradata/db/DATA01.dbf' SIZE 500M
UNIFORM. SIZE128k; #指定區尺寸為128k,如不指定,區尺寸預設為64k
刪除表空間
DROP TABLESPACE data01 INCLUDING CONTENTS AND DATAFILES;
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/12932950/viewspace-611345/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- oracle segment space management and extent management幾則Oracle
- Undo Space Acquisition and Management (299)UI
- Oracle OCP 1Z0-053 Q635(FRA Space Management)Oracle
- [zt] dmt、lmt、mssm, assm (SEGMENT SPACE MANAGEMENT AUTO) 的一點總結SSM
- Oracle10g New Feature --12. ASSM ( Automatic Segment Space Management )OracleSSM
- ocp 19c考題,科目082考試題(23)- space management within blocks managed ASSMBloCSSM
- Hilbert Space
- Memory Management in RustRust
- PostgreSQL Role ManagementSQL
- SQL management baseSQL
- Credit Management(SD)
- SQL Plan ManagementSQL
- No space left on devicedev
- Tablespace Space Script
- Oracle Cluster Time ManagementOracle
- memory management unit (MMU)
- Linux Memory ManagementLinux
- SQL Plan Management(SPM)SQL
- dispute management and new ES
- Management on database linkDatabase
- Management of Remote Dependencies (252)REM
- Master Data Management UpdateAST
- Management of Materials With Shelf Life
- show_space.sqlSQL
- Oracle DBMS_SPACEOracle
- space.itpub印象
- Stability Study with SAP Quality Management
- User Exits for WM (Warehouse Management)
- JMX-Java Management ExtensionsJava
- ASM(Automatic Storage Management)ASM
- Oracle Management Server Could Not Be StartedOracleServer
- SQL Plan Management介紹SQL
- SAP 批次管理(Batch management)BAT
- Axis2 Session ManagementSession
- Local and Remote Dependency Management (250)REM
- Oracle Lock Management Services (365)Oracle
- Websphere (WAS) Work Load ManagementWeb
- Overview of Transaction Management (142)View