Oracle 11G空表无法导出处理

通过exp进行数据导出的时候,如果表的数据为空,则会出现警告,并且表也不会导出,不利于数据恢复。

可以通过以下方法进行解决:

一、使用ALLOCATE EXTENT,可以导出之前已经存在的空表

--查询当前用户中所有记录数为0的表
select table_name from user_tables where NUM_ROWS=0;
--拼接SQL字符串
Select 'alter table '||table_name||' allocate extent;' from user_tables where num_rows=0 or num_rows is null
--将查询出来的数据进行执行,更改表信息
--例如:alert table t_1 allocate extendt;
--说明:
--ALLOCATE EXTENT语法描述:
 ALLOCATE EXTENT { SIZE integer [K | M] | DATAFILE 'filename' | INSTANCE integer }
   -----------
   可以针对数据表、索引、物化视图等手工分配Extent。
   ALLOCATE EXTENT使用样例:
    ALLOCATE EXTENT
    ALLOCATE EXTENT(SIZE integer [K | M])
    ALLOCATE EXTENT(DATAFILE 'filename')
    ALLOCATE EXTENT(INSTANCE integer)  www.2cto.com
    ALLOCATE EXTENT(SIZE integer [K | M]   DATAFILE 'filename')
    ALLOCATE EXTENT(SIZE integer [K | M]   INSTANCE integer)
   针对数据表操作的完整语法如下:
   -----------
   ALTER TABLE [schema.] table_name ALLOCATE EXTENT [({ SIZE integer [K | M] | DATAFILE 'filename' | INSTANCE integer})]

二、修改数据库参数(deferred_segment_creation)设置:

设置deferred_segment_creation 参数为FALSE来禁用"段推迟创建"(也就是直接创建segment),无论是空表还是非空表,都分配segment。

在sqlplus中,执行如下命令:

sqlplus / as sysdba
SQL>alter system set deferred_segment_creation=false;
#查看:
SQL>show parameter deferred_segment_creation;

注意:该值设置后只对后面新增的表产生作用,对之前建立的空表(已经存在的)不起作用,仍不能导出。

   并且要重新启动数据库,让参数生效,为了使得后续新增的表也可以导出,建议使用第二种方法

参考:

http://blog.sina.com.cn/s/blog_5f0e9ca50101it7n.html

http://www.cnblogs.com/live365wang/p/4482585.html

原文地址:https://www.cnblogs.com/wlzjdm/p/6667019.html