eygle.com   eygle.com
eygle.com eygle
eygle.com  
 

« 未雨绸缪 防患未然-《数据安全警示录》序言 | Blog首页 | 2012 Oracle中高级技能培训-性能优化深入浅析 »

只读表空间中创建对象-deferred_segment_creation
modb.pro

有朋友发现可以在只读表空间里创建新的空表,提出疑问,这实际上是Oracle Database 11g的新特性Deferred Segment Creation在建表时的"副作用",由于无需分配空间,新建的数据表只需要增加元数据,就出现了可以在只读表空间中创建空表的现象。

以下是一个测试演示过程,当deferred_segment_creation设置为TRUE时,可以在只读表空间中创建数据表,但是当插入记录需要分配空间时,则会出现错误:
SQL> show parameter deferred_segment_creation

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
deferred_segment_creation            boolean     TRUE
SQL> alter tablespace users read only;

Tablespace altered.

SQL> connect eygle/eygle                    
Connected.
SQL> create table eygle (id number) tablespace users;

Table created.

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

TABLE_NAME                     TABLESPACE_NAME
------------------------------ ------------------------------
EYGLE                          USERS

SQL> insert into eygle values(1);
insert into eygle values(1)
            *
ERROR at line 1:
ORA-01647: tablespace 'USERS' is read-only, cannot allocate space in it
当设置该参数为False时,则创建数据表时就需要分配空间,直接抛出异常,无法创建:
SQL> alter session set deferred_segment_creation=false;

Session altered.

SQL> create table e (id number) tablespace users;
create table e (id number) tablespace users
*
ERROR at line 1:
ORA-01647: tablespace 'USERS' is read-only, cannot allocate space in it


SQL>  alter session set deferred_segment_creation=true;

Session altered.

记录一下文档中的描述:
You can drop items, such as tables or indexes, from a read-only tablespace, but you cannot create or alter objects in a read-only tablespace. You can execute statements that update the file description in the data dictionary, such as ALTER TABLE...ADD or ALTER TABLE...MODIFY, but you will not be able to utilize the new description until the tablespace is made read/write.

是以为新特性记录。


历史上的今天...
    >> 2018-07-16文章:
    >> 2011-07-16文章:
    >> 2008-07-16文章:
    >> 2007-07-16文章:
           摄影习作-百年之好合
           Tools:Linux下的SYSSTAT工具
    >> 2006-07-16文章:

By eygle on 2012-07-16 11:10 | Comments (0) | Oracle12c/11g | 3025 |


CopyRight © 2004~2020 云和恩墨,成就未来!, All rights reserved.
数据恢复·紧急救援·性能优化 云和恩墨 24x7 热线电话:400-600-8755 业务咨询:010-59007017-7040 or 7037 业务合作: marketing@enmotech.com