oracle 11不能导出空表的详细解决方法

oracle 11不能导出空表的详细解决方法

第一步:分别执行下面两句话

select t.table_name,t.num_rows from user_tables t
select table_name from user_tables where NUM_ROWS=0;
若查询的空表数相同

第二步:对比查询结果,若查询的空表数(行数为0)是否相同,若相同则执行下面语句:

1.先找出空表
select ‘alter table ‘||table_name||’ allocate extent;’ from user_tables where num_rows=0
2. 对空表执行容量替换,即执行下面sql语句,例如(红字为要替换的表名):
alter table TBL_1 allocate extent;
alter table TBL_2 allocate extent;
alter table TBL_3 allocate extent;
alter table TBL_4 allocate extent;
……

第三步:若空表数量不相同,则表明库表不是实时,用num_rows 统计不准确,要用下面方法:

1、创建一个函数:
create or replace function count_rows(table_name in varchar2,
owner in varchar2 default null)
return number
authid current_user
IS
num_rows number;
stmt varchar2(2000);
begin
if owner is null then
stmt := ‘select count() from “’||table_name||’”’;
else
stmt := 'select count(
) from "’||owner||’"."’||table_name||’"’;
end if;
execute immediate stmt into num_rows;
return num_rows;
end;

2、执行下面语句,找出实际空表数
select table_name, count_rows(table_name) nrows from user_tables order by nrows

3、对空表执行容量替换,即执行下面sql语句,例如(红字为要替换的表名):
alter table TBL_1 allocate extent;
alter table TBL_2 allocate extent;
alter table TBL_3 allocate extent;
alter table TBL_4 allocate extent;

参考文献

链接: https://blog.csdn.net/iwes_c/article/details/78337597?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.channel_param&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.channel_param.

在这里插入图片描述

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值