您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息
免费发信息

如何在oracle 11g 中导出空表

2024/4/25 23:53:15发布5次查看
如何在oracle 11g 中导出空表 由于oracle 11g的 延迟段创建的新特性,导致在没有数据插入时,oracle是不会分配数据段的,进而导致exp 是不能导出11g数据库的空表的。 当然采用expdp就不存在这个问题了。 expdp hr/hr schemas=hr dumpfile=expdp.dmp director
如何在oracle 11g 中导出空表
由于oracle 11g的 延迟段创建的新特性,导致在没有数据插入时,oracle是不会分配数据段的,进而导致exp 是不能导出11g数据库的空表的。
当然采用expdp就不存在这个问题了。
expdp hr/hr schemas=hr dumpfile=expdp.dmp directory=dbtest
conn hr/hr
select table_name,num_rows from user_tables;
table_name num_rows
------------------------------ ----------
locations 23
emp_1 0
part_time_employees 0
test3 5
test1 5
test 5
pc_well_test 2
pc_alarm_sort_test 1
mview_pc_well_test 2
mv_capabilities_table 14
t 0
test2
sys_export_schema_01
sys_export_schema_02
hourly_employees 0
countries 25
admin_ext_employees
admin_work_area
employees 107
departments 27
digits 2
regions 4
job_history 10
jobs 19
24 rows selected.
为什么这里的num_rows为空呢?
那是因为表刚建立,数据字典中还没有这个表相关的统计信息呢。
sql> select 'alter table '||table_name||' allocate extent;' from user_tables where
num_rows=0
'altertable'||table_name||'allocateextent;'
-----------------------------------------------------------
alter table part_time_employees allocate extent;
alter table emp_1 allocate extent;
alter table t allocate extent;
alter table hourly_employees allocate extent;
所以对于网上一些在oracle11g上先使用手工分配extent 再使用exp来导数据库,在实际上效果不怎么地,反而是多次一举直接使用expdp来导oracle 11g数据库中空表来的方便多了。
当然对那些要从11g导低版本,还是可以的采用这个办法,,但是要注意,要么对所有相关的表进行分析系,然后使用上述那个批量脚本。或者不分析表,直接手工用ue编辑分配extent的命令。
sql> select table_name,num_rows from user_tables where num_rows=0;
table_name num_rows
------------------------------ ----------
part_time_employees 0
emp_1 0
t 0
hourly_employees 0
补充信息:
user_tables describes the relational tables owned by the current user. its columns (except
for owner) are the same as those in all_tables. to gather statistics for this view, use the
dbms_stats package.
收集表的统计信息:
analyze table xxx compute statistics;
or
exec dbma_stats.gather_table_stats('user', 'table');
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录