日期:2014-05-16 浏览次数:20472 次
oracle 11g R2中exp不能导出空表的解决方法
oracle 11g Realease 2(11.2.0.1)中,在导出空表的时候,会报错。查了一下原因,原来,该版本中做了一项优化,在建表的时候,不会分配存储空间,只有在第一次insert数据的时候,才会分配存储空间。这在系统中有很多空表时,能节省大量的存储空间。但是如果系统只有少量的空间时,就没什么必要。这项优化还会引起配额错误(Quota Errors),可参考http://www.dba-oracle.com/t_oracle_deferred_segment_creation.htm。这个问题在11.2.0.2中得到了修复。
为此,oracle提供了一个deferred_segment_creation参数来进行配置,这个参数默认值为true。所以在创建表时如果没有把这个参数指定为false,那么创建之后,又没有添加任何数据,在使用exp导出时就会出错。来看官方文档解释:
|
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 deferredsegment creation. If set to true, then segments for non-partitioned tables and their dependent objects (LOBs, indexes) will not be created untilthe first row is inserted
into the table.
Before creating a set of tables, if it is known that asignificant number of them will not be populated, then consider setting thisparameter to true. This saves disk space and minimizes install time.
指定段延迟创建,如果设置成true,那么非分区表和依赖它的对象(LOB,索引)将不分配存储空间,直到往表中插入第一条数据时才分配。
在创建表之前,如果知道不会往里面写入数据,那可心考虑把这个参数设置成true。这样可以节省存储空间并减少表创建时间。
好,知道了原因,就好办了。来看解决办法:
1、最傻X的方法就是往表中写一条数据,然后删除或rollback掉,再导出就没问题了。但是这有个问题,如果有很多的表,那太费时间了。那就用第二种方法。
2、通过修改deferred_segment_creation参数。
查看该参数的值:
SQL> showparameter deferred_segment_creation; NAME TYPE VALUE ------------------------------------ ----------------------------------------- deferred_segment_creation boolean TRUE
alter system set deferred_segment_creation = false;
set deferred_segment_creation = [TRUE | FALSE]
segment creation { IMMEDIATE | DEFERRED }alter table <tablename> allocate extent
select'altertable' ||table_name || ' allocate extent;' from user_tables where num_rows =0;