加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Oracle 11g导出空表、少表的解决办法

发布时间:2020-12-12 13:24:44 所属栏目:百科 来源:网络整理
导读:执行下面语句: begin ? for obj in (select ‘alter table ‘||table_name||‘ allocate extent‘ objsql from user_tables where num_rows=0) loop ??? execute immediate obj.objsql; ? end loop; end; ================================================

执行下面语句:

begin
? for obj in (select ‘alter table ‘||table_name||‘ allocate extent‘ objsql from user_tables where num_rows=0) loop
??? execute immediate obj.objsql;
? end loop;
end;

==================================================================================

批量处理空表

?????? 首先使用下面的sql语句查询一下当前用户下的所有空表

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

  假设我们这里有空表TBL_1,TBL_2,TBL_3,TBL_4,则查询结果如下:

alter table TBL_1 allocate extent; alter table TBL_2 allocate extent; alter table TBL_3 allocate extent; alter table TBL_4 allocate extent;

  最后我们把上面的SQL语句执行就可以了。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读