-----------创建中间表
begin
dbms_stats.create_stat_table('test','test_table');
end;
/
-----------查询中间表,确认没有记录
testROSE> select count(*) from test_table;
COUNT(*)
----------
0
-----------在schema级别导出统计信息
testROSE> exec dbms_stats.export_schema_stats('test','test_table');
PL/SQL procedure successfully completed.
testROSE> select count(*) from test_table;
COUNT(*)
----------
26
----------使用exp,imp工具把这个表导到目标数据库
[oraclerose tmp]$ exp test/rose tables=test_table file=/tmp/statis.dmp
. . exporting table TEST_TABLE 26 rows exported
[oraclerose tmp]$ imp parfile=/tmp/pa.sh ignore=y
. . importing table "TEST_TABLE" 26 rows imported
---------删除scott用户下的表统计信息(测试需要)
scottROSE> begin
2 dbms_stats.delete_schema_stats('scott');
3 end;
4 /
PL/SQL procedure successfully completed.
scottROSE> select num_rows,last_analyzed from user_tab_statistics;
NUM_ROWS LAST_ANALYZE
---------- ------------
----------导入统计信息
begin
dbms_stats.import_schema_stats('scott','test_table');
end;
/
scottROSE> select num_rows,last_analyzed from user_tab_statistics;
NUM_ROWS LAST_ANALYZE
---------- ------------
发现还是没有统计信息。
update test_table set c5='SCOTT';
commit;
begin
dbms_stats.import_schema_stats('scott','test_table');
end;
/
scottROSE> select num_rows,last_analyzed from user_tab_statistics;
NUM_ROWS LAST_ANALYZE
---------- ------------
0 18-SEP-10
4 18-SEP-10
14 18-SEP-10
5 18-SEP-10
6 rows selected.
经过实验可以看出,默认的是从同一个方案之间的导入导出,如果要不同方案,需要修改test_table的c5字段。
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/22034023/viewspace-689178/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/22034023/viewspace-689178/