Oracle Initialization Parameters:DEFERRED

WBOY
發布: 2016-06-07 15:51:06
原創
1092 人瀏覽過

官方文档的说明: DEFERRED_SEGMENT_CREATION Property Description Parameter typeBoolean Default value true Modifiable ALTER SESSION, ALTER SYSTEM Range of valuestrue | false Basic No DEFERRED_SEGMENT_CREATION specifies the semantics of defer

官方文档的说明:
DEFERRED_SEGMENT_CREATION


Property                Description
Parameter typeBoolean
Default value  true
Modifiable        ALTER SESSION, ALTER SYSTEM
Range of valuestrue | 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; 


相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!