ITPub博客

首页 > 数据库 > Oracle > 11g R2延时段特性

11g R2延时段特性

原创 Oracle 作者:banana_62 时间:2017-06-15 22:21:05 0 删除 编辑

Beginning with Oracle Database 11g Release 2, when you create heap-organized tables in a locally managed tablespace, the database defers table segment creation until the first row is inserted.

从11G R2开始,当我们在在一个本地管理的表空间中创建堆表时,就会默认使用延迟段创建,只有当表中插入数据的时候,才会建立表段。当DEFERRED_SEGMENT_CREATION 为true时这个延迟段创建特性才会生效,不过也可以在创建表的时候指定段的创建模式(SEGMENT CREATION DEFERRED,SEGMENT CREATION IMMEDIATE)。延时段特性可以在堆表段,lob段,索引段,分区表段,分区lob段,分区索引段,物化视图段上使用。


我们创建一个延迟段属性的表

CREATE TABLE scott.deferred_tab1 (

    col1 NUMBER(8),

    col2 clob

)  

SEGMENT CREATION DEFERRED;

在*_TABLES,*_LOBS中可以看到表和lob的定义

SQL> select owner,table_name,tablespace_name from dba_tables where table_name='DEFERRED_TAB1';

OWNER            TABLE_NAME      TABLESPACE_NAME          

------------------------- --------------------------- --------------------------

SCOTT            DEFERRED_TAB1                  USERS  


SQL> select owner,table_name,segment_name from dba_lobs where table_name ='DEFERRED_TAB1';

OWNER                 TABLE_NAME                     SEGMENT_NAME

------------------ ------------------------------ ------------------------------

SCOTT                 DEFERRED_TAB1                  SYS_LOB0000165508C00002$$

在*_SEGMENTS试图中试图寻找对应段

SQL> select owner,segment_name,segment_type from dba_segments where segment_name='DEFERRED_TAB1';

OWNER                    SEGMENT_NAME            SEGMENT_TYPE

--------------------------------------------

SQL> select owner,segment_name,segment_type from dba_segments where segment_name='SYS_LOB0000165508C00002$$';

OWNER         SEGMENT_NAME          SEGMENT_TYPE

------------------------------

在表中插入数据,再次查找对应的段

SQL> insert into scott.deferred_tab1 values(1,1001);

1 row inserted


SQL>  select owner,table_name,segment_name from dba_lobs where table_name ='DEFERRED_TAB1';

OWNER                          TABLE_NAME                     SEGMENT_NAME

------------------------------ ------------------------------ ------------------------------

SCOTT                          DEFERRED_TAB1           SYS_LOB0000165508C00002$$

 

SQL> select owner,segment_name,segment_type from dba_segments where segment_name='SYS_LOB0000165508C00002$$';

OWNER        SEGMENT_NAME           SEGMENT_TYPE

------------------------------ ----------------------------------------------------------

SCOTT              SYS_LOB0000165508C00002$$     LOBSEGMENT


SQL> select owner,segment_name,segment_type from dba_segments where segment_name='DEFERRED_TAB1';

 

OWNER        SEGMENT_NAME          SEGMENT_TYPE

------------------------------ --------------------------------------------------

SCOTT           DEFERRED_TAB1              TABLE

 

在插入语句后,scott表段和表中的lob段才建立,这就是延时段创建。在使用sqlload,exp导出的时候延时段可能会不被导出,如果没有真的段建立在数据库中。

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/31461640/viewspace-2140809/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2017-05-18

  • 博文量
    71
  • 访问量
    65041