Oracle Initialization Parameters:DEFERRED_SEGMENT_CREATION

官方文檔的說明:
DEFERRED_SEGMENT_CREATION


Property                 Description
Parameter type Boolean
Default value   true
Modifiable         ALTER SESSION, ALTER SYSTEM
Range of values true | false
Basic                 No
         DEFERRED_SEGMENT_CREATION specifies the semantics of deferred segment creation. If set to true, then segments for tables and their dependent objects (LOBs, indexes) will not be created until the first row is inserted into the table.
         Before creating a set of tables, if it is known that a significant number of them will not be populated, then consider setting this parameter to true. This saves disk space and minimizes install time.

         DEFERRED_SEGMENT_CREATION具體指segment延遲創建,如果DEFERRED_SEGMENT_CREATION的值時true,則當table創建時,該table以及依賴它的lob,index的segment都不會創建,知道第一行記錄插入到該table。DEFERRED_SEGMENT_CREATION 參數從11.2.0.1引進,默認值爲true;如果要使其恢復老版本功能,設置該參數爲false.

        DEFERRED_SEGMENT_CREATION效果驗證:

SQL>select * from v$version;

BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
PL/SQL Release 11.2.0.3.0 - Production
CORE    11.2.0.3.0      Production
TNS for Linux: Version 11.2.0.3.0 - Production
NLSRTL Version 11.2.0.3.0 - Production

SQL>show parameter DEFERRED_SEGMENT_CREATION

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
deferred_segment_creation            boolean     TRUE

SQL>create table t_hh (id number,name varchar2(10));

Table created.

SQL>create index ind_t_hh_id on t_hh(id);

Index created.

SQL>Select segment_name,segment_type from user_segments where segment_name in ('T_HH','IND_T_HH_ID');

no rows selected


SQL>insert into t_hh values(998,'hengheng');

1 row created.

SQL>Select segment_name,segment_type from user_segments where segment_name in ('T_HH','IND_T_HH_ID');

SEGMENT_NAME                                                                      SEGMENT_TYPE
--------------------------------------------------------------------------------- ------------------
T_HH                                                                              TABLE
IND_T_HH_ID                                                                       INDEX

    這裏我們可以看到,當insert發生的時候,數據庫會給該表創建segment並分配extent,無論該insert 操作是commit or rollback。but,deferred_segment_creation 參數對sys,system用戶是無效的,下面我們來驗證下:

SQL>show user
USER is "SYS"
SQL>create table t_sys_hh (id number,name varchar2(10));

Table created.

Elapsed: 00:00:00.17
SQL>Select segment_name,segment_type from dba_segments where segment_name = 'T_SYS_HH';

SEGMENT_NAME                                                                      SEGMENT_TYPE
--------------------------------------------------------------------------------- ------------------
T_SYS_HH                                                                          TABLE
   

    對於古老的導出工具exp來說,我們無法導出沒有segment的表,故在exp之前需要給表分配extent,可以用:alter table tablename allocate extent; 


發佈了34 篇原創文章 · 獲贊 26 · 訪問量 9萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章