11g中有个新特性,当表无数据时,不分配segment以节省空间。为了使空表也能导出需要如下处理:
方法一:select 'alter table '||table_name||' allocate extent;' from user_tables where segment_created='YES';生成的SQL语句执行一下即完成所有空表段空间的分配
方法二:建库时关闭延迟段空间分配的功能:alter system set deferred_segment_creation=false;
如果数据库已经创建好,那么就只能使用第一种方法了,但上面的方法一很麻烦,以下是我的方法:
①收集统计信息
exec dbms_stats.gather_schema_stats(ownname => 'emp') ; 统计表信息,这样all_tables里面的信息才准确,如num_rows
②批处理:自动为表分配段空间
方法一:select 'alter table '||table_name||' allocate extent;' from user_tables where segment_created='YES';生成的SQL语句执行一下即完成所有空表段空间的分配
方法二:建库时关闭延迟段空间分配的功能:alter system set deferred_segment_creation=false;
如果数据库已经创建好,那么就只能使用第一种方法了,但上面的方法一很麻烦,以下是我的方法:
①收集统计信息
exec dbms_stats.gather_schema_stats(ownname => 'emp') ; 统计表信息,这样all_tables里面的信息才准确,如num_rows
②批处理:自动为表分配段空间
DECLARE
BEGIN
FOR I IN (select 'alter table '||OWNER||'.' || table_name || ' allocate extent' as aaa from all_tables where segment_created = 'NO' and OWNER IN ('EMP') order by aaa asc) LOOP
execute immediate I.aaa;
end loop;
end;
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/25960404/viewspace-1128766/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/25960404/viewspace-1128766/