exp无法导出空表的问题

--描述:由于11gR2中有一个新特性,当表无数据时,不会分配segment以节省空间
--所以当exp导出时如果是没有分配segment的空表就不会被导出

--解决方法:
1、insert一行,在rollback就产生了segment
在空表中插入数据再删除,就会产生segment了,则可以用exp导出空表了

2、设置参数defferred_segment_creation 参数为false
该参数值默认是TRUE,当改为FALSE时,无论是空表还是非空表,都分配segment
alter system set deferred_segment_creation=falsescope=both;
--注意:该值设置后对之前的空表不产生作用,仍不能导出,只能对后面新增的表产生作用。如需导出之前的空表,只能用第一种方法

3、手动分配segment空间
alter table table_name allocate extent;
执行语句,强行为表分配空间修改segment值,然后再导出即可导出空表了



--实验
--实验环境:本地linux虚拟机,Oracle数据库版本11gR2

--创建相关测试表
create table scott.empty_1
(id number,
name varchar2(10),
sex varchar2(5));
create table scott.empty_2
(id number,
name varchar2(10),
sex varchar2(5));

--1、尝试导出空表scott.empty_1
[oracle@localhost ~]$ cd /home/software/exp_dir
[oracle@localhost exp_dir]$ exp scott/scottfile=exp_empty1.dmp tables=empty_1 log=exp_empty1

--结果:没有报错,但是显示找不到表empty_1
About to export specified tables via Conventional Path...
EXP-00011: SCOTT.EMPTY_1 does not exist
Export terminated successfully with warnings.


--2、用方法1导出空表empty_1
insert into scott.empty_1 values (1,'test','male');
delete from scott.empty_1;
commit;
--再执行导出语句
[oracle@localhost exp_dir]$ exp scott/scottfile=exp_empty2.dmp tables=empty_1 log=exp_empty2

--结果:成功导出空表
About to export specified tables via Conventional Path...
. . exporting table                    EMPTY_1         0 rowsexported
Export terminated successfully without warnings.


--3、用方法2导出空表
alter system set deferred_segment_creation=falsescope=both;
--创建新的表
create table scott.empty_3
(id number,
name varchar2(10),
sex varchar2(5));
--导出empty_2和新的empty_3
[oracle@localhost exp_dir]$ exp scott/scottfile=exp_empty3.dmp tables="(empty_2,empty_3)" log=exp_empty3

--结果:empty_3成功导出,empty_2找不到
About to export specified tables via Conventional Path...
EXP-00011: SCOTT.EMPTY_2 does not exist
. . exporting table                    EMPTY_3         0 rowsexported
Export terminated successfully with warnings.

--这时候去查segment视图,发现empty_1和empty_3都有,而empty_2没有
select * from dba_segments where owner='SCOTT';


--4、用方法3导出表empty_2
alter table scott.empty_2 allocate extent;
--再查询segment视图发现empty_2也有了
select * from dba_segments where owner='SCOTT';
--导出empty_2
[oracle@localhost exp_dir]$ exp scott/scottfile=exp_empty4.dmp tables="(empty_2)" log=exp_empty4

--结果:顺利导出空表empty_2
About to export specified tables via Conventional Path...
. . exporting table                    EMPTY_2         0 rowsexported
Export terminated successfully without warnings.



--删除测试dmp文件和log文件,删除表
[oracle@localhost exp_dir]$ rm exp*
drop table scott.empty_1 purge;
drop table scott.empty_2 purge;
drop table scott.empty_3 purge;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值