Oracle数据库导出空表操作

本文介绍了解决Oracle 11G中空表无法导出的问题,探讨了11G的新特性——延迟段创建,并提供了两种解决方法:通过插入并回滚数据来创建segment,或修改deferred_segment_creation参数。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一、问题原因:

   11G中有个新特性,当表无数据时,不分配segment,以节省空间

    1、insert一行,再rollback就产生segment了。

 

       该方法是在在空表中插入数据,再删除,则产生segment。导出时则可导出空表。

 

    2、设置deferred_segment_creation 参数

 

      show parameter deferred_segment_creation

 

  NAME                                TYPE        VALUE

 

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

 

  deferred_segment_creation           boolean     TRUE

 

  SQL>alter system set deferred_segment_creation=false;

 

   系统已更改。

 

  SQL> show parameter deferred_segment_creation

 

  NAME                                TYPE        VALUE

 

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

 

 

  deferred_segment_creation            boolean     FALSE

 

    该参数值默认是TRUE,当改为FALSE时,无论是空表还是非空表,都分配segment。

 

    需注意的是:该值设置后对以前导入的空表不产生作用,仍不能导出,只能对后面新增的表产生作用。如需导出之前的空表,只能用第一种方法。

 

二、解决方法:

 

    1、先查询一下所有用户下的所有空表

     select table_name from all_tables where NUM_ROWS=0;

     当前用户下的表

     select table_name from user_tables where NUM_ROWS=0;

 

    2、用以下这句查找空表

所有用户:

     select'alter table '||owner||'.'||table_name||' allocate extent;'from all_tables where num_rows=0;

当前用户:

    select'alter table '||table_name||' allocate extent;'from user_tables where num_rows=0;

      把查询结果导出,执行导出的语句

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

 

alter table SYS.PROXY_ROLE_DATA$ allocateextent;

 

 

alter table SYS.UET$ allocate extent;

 

 

alter table SYS.PROXY_DATA$ allocateextent;

 

 

alter table SYS.FET$ allocate extent;

 

 

alter table SYS.OBJERROR$ allocate extent;

 

 

alter table SYS.UGROUP$ allocate extent;

 

 

alter table SYS.SUPEROBJ$ allocate extent;

 

 

alter table SYS.REFCON$ allocate extent;

 

 

alter table SYS.VIEWCON$ allocate extent;

 

 

alter table SYS.OBJPRIV$ allocate extent;

 

 

alter table SYS.DEFROLE$ allocate extent;

 

 

alter table SYS.ECOL$ allocate extent;

 

 

alter table SYS.EV$ allocate extent;

 

 

alter table SYS.EVCOL$ allocate extent;

 

 

alter table SYS.LINK$ allocate extent;

 

 

alter table SYS.RECYCLEBIN$ allocateextent;

 

 

alter table SYS.IND_ONLINE$ allocateextent;

 

 

alter table SYS.JIJOIN$ allocate extent;

 

 

alter table SYS.JIREFRESHSQL$ allocateextent;

 

 

alter table SYS.TRIGGERCOL$ allocateextent;

 

 

alter table SYS.TRIGGERJAVAF$ allocateextent;

 

 

alter table SYS.TRIGGERJAVAS$ allocateextent;

 

 

alter table SYS.TRIGGERJAVAC$ allocateextent;

 

 

alter table SYS.TRIGGERJAVAM$ allocateextent;

 

 

alter table SYS.VIEWTRCOL$ allocate extent;

 

 

alter table SYS.TRIGGERDEP$ allocateextent;

 

 

alter table SYS.INDREBUILD$ allocateextent;

 

 

alter table SYS.COMPRESSION$ allocateextent;

 

 

alter table SYS.TRANSIENT_IOT$ allocateextent;

 

 

alter table SYS.SQL$ allocate extent;

 

 

alter table SYS.SQL$TEXT allocate extent;

 

 

alter table SYS.SQLOBJ$AUXDATA allocateextent;

 

 

alter table SYS.OBJECT_USAGE allocateextent;

 

 

alter table SYS.ERROR$ allocate extent;

 

 

alter table SYS.NCOMP_DLL$ allocate extent;

 

 

alter table SYS.ASSEMBLY$ allocate extent;

 

 

alter table SYS.DIANA_VERSION$ allocateextent;

 

 

alter table SYS.PENDING_TRANS$ allocateextent;

 

 

alter table SYS.PENDING_SESSIONS$ allocateextent;

 

 

alter table SYS.PENDING_SUB_SESSIONS$allocate extent;

 

 

…………………

    3、然后再执行

 

      exp用户名/密码@数据库名file=/home/oracle/exp.dmp log=/home/oracle/exp_smsrun.log   成功!


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值