轻松解决oracle11g 空表不能exp导出的问题。

时间:2022-03-16 20:38:04

解决方法:
 
1插入一条数据(或者再删除),浪费时间,有时几百张表会累死的。
2创建数据库之前
使用代码:

Sql代码 
alter system set  deferred_segment_creation=false; 
 
调整再建表
这两种方都不好
下面是终极方法:
 
先查询一下哪些表是空的:

Sql代码 
select table_name from user_tables where NUM_ROWS=0; 
 
 
下面我们通过select 来生成修改语句:
Sql代码 
select 'alter table '||table_name||' allocate extent;' from user_tables where num_rows=0 
 
然后就在结果窗口里面生成了下面那些东西:

select 'analyze table '||table_name||' compute statistics;' from user_tables;

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

 在工作中有时需要对现有数据库进行清理,统计,分析,这就需要知道库里有那些表,都有多少数据,在Oracle中,可用使用视图USER_TABLES:

  SELECT * FROM USER_TABLES;

USER_TABLES提供了丰富的信息,其中较为重要的就是表中的数据行数(列NUM_ROWS),但这个列行数并不是准确的行数,可能与查询具体表的COUNT结果一致

  这是因为num_rows是根据分析表后取得数据行数,必须先Analyze Table才能取得准确的数据行数。

  如果想查询所有用户表中的列,可以使用USER_TAB_COLUMNS,可查询某个列都在哪些表中出现。

  SELECT * FROM USER_TAB_COLUMNS;

  另外,使用user_tables可查询当前用户的表;all_tables可查询所有用户的表;dba_tables查询包括系统表的所有表