11GR2的新特性Deferred Segment Creation

今天在看Apress.Pro.Oracle.Database.11g.Administration.Dec.2010.pdf时候,发现11GR2下有一个新特性,叫做Deferred Segment Creation.

按照书上的例子测试看看并且摘要如下:
    Starting with Oracle Database 11g Release 2, when you create a table, the creation of the associated segment is deferred until the first row is inserted into the table. This feature has some interesting implications. For example, if you have thousands of objects that you’re initially creating for an application (such as when you first install it), no space is consumed by any of the tables (or associated indexes) until data is inserted into the application tables. This means the initial DDL runs more quickly when you create a table, but the first INSERT statement runs slightly slower.

SQL> create table inv(inv_id number, inv_desc varchar2(30));
SQL> select  table_name ,segment_created from user_tables where table_name='INV';
TABLE_NAME                     SEG
------------------------------         ---
INV                                          NO

select  segment_name ,segment_type ,bytes from user_segments where segment_name='INV' and segment_type='TABLE';
no rows selected

SQL> insert into inv values(1,'BOOK');
Rerun the query, selecting from USER_SEGMENTS, and notice that a segment has been created:
SEGMENT_NAME    SEGMENT_TYPE            BYTES
--------------- ------------------ ----------
INV             TABLE                   65536

■ Note You can disable the deferred-segment-creation feature by setting the database-initialization parameter
DEFERRED_SEGMENT_CREATION to FALSE. The default for this parameter is TRUE.

我在建立表后导出表的定义如下:
CREATE TABLE "SCOTT"."INV"
   (    "INV_ID" NUMBER,
    "INV_DESC" VARCHAR2(30)
   ) SEGMENT CREATION DEFERRED
  PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
  TABLESPACE "USERS"

插入后,在导出如下:
CREATE TABLE "SCOTT"."INV"
   (    "INV_ID" NUMBER,
    "INV_DESC" VARCHAR2(30)
   ) SEGMENT CREATION IMMEDIATE
  PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "USERS"

这样建立的表会很快,但是开始插入的时候要浪费一些时间.

另外这个还导致另外一个小问题exp/imp这些空表无法导入:

exp scott/xxx file=test.dmp

alter table SCOTT.INV rename to INV1

imp scott/btbtms file=test.dmp full=Y
可以发现表inv没有导入!

alter table SCOTT.INV1 rename to INV
再执行如下:

$ exp scott/btbtms file=test.dmp tables=inv
Export: Release 11.2.0.1.0 - Production on Sat May 21 00:12:08 2011
Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Export done in ZHS16GBK character set and AL16UTF16 NCHAR character set

About to export specified tables via Conventional Path ...
EXP-00011: SCOTT.INV does not exist
Export terminated successfully with warnings.



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

转载于:http://blog.itpub.net/267265/viewspace-695835/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值