資料泵匯出索引資料和統計資訊嗎
關於在資料泵問題:
(1)索引資料匯出嗎?
(2)源表統計資料匯出/匯入嗎?
1建立測試表
drop table test;
create table test
as
select dbms_random.string('x',50) as x from dual
connect by level<=1e6;
create index idx_test_x on test(x);
begin
dbms_stats.gather_table_stats(user,'TEST');
end;
/
select table_name,num_rows,blocks,to_char(last_analyzed,'YYYYMMDD hh24miss') as l_anay from user_tables where table_name='TEST';
TABLE_NAME NUM_ROWS BLOCKS L_ANAY
---------- ---------- ---------- --------------------
TEST 997971 7884 20140315 153237
select index_name,leaf_blocks,to_char(last_analyzed,'YYYYMMDD hh24miss') as l_anay from user_indexes where table_name='TEST';
INDEX_NAME LEAF_BLOCKS L_ANAY
--------------- ----------- --------------------
IDX_TEST_X 8467 20140315 153238
col segment_name for a20
select segment_name,bytes/1024/1024 from user_segments where segment_name in('TEST','IDX_TEST_X');
SEGMENT_NAME BYTES/1024/1024
-------------------- ---------------
TEST 62
IDX_TEST_X 72
2修改統計資料
begin
dbms_stats.set_table_stats(ownname => user,tabname => 'TEST',numrows => 1000,numblks => 100);
end;
/
begin
dbms_stats.set_index_stats(ownname => user,indname => 'IDX_TEST_X',numlblks => 100);
end;
/
select table_name,num_rows,blocks,to_char(last_analyzed,'YYYYMMDD hh24miss') as l_anay from user_tables where table_name='TEST';
TABLE_NAME NUM_ROWS BLOCKS L_ANAY
---------- ---------- ---------- --------------------
TEST 1000 100 20140315 153457
select index_name,leaf_blocks,to_char(last_analyzed,'YYYYMMDD hh24miss') as l_anay from user_indexes where table_name='TEST';
INDEX_NAME LEAF_BLOCKS L_ANAY
--------------- ----------- --------------------
IDX_TEST_X 100 20140315 153457
3包含/不包含索引匯出
(1)不包含索引匯出
mah]$ expdp \'sys/sys as sysdba\' directory='DMP_DIR' tables=MH.TEST dumpfile=test.dmp exclude=INDEX estimate=statistics
Export: Release 10.2.0.1.0 - Production on Saturday, 15 March, 2014 15:36:19
Copyright (c) 2003, 2005, Oracle. All rights reserved.
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
Starting "SYS"."SYS_EXPORT_TABLE_01": 'sys/******** AS SYSDBA' directory=DMP_DIR tables=MH.TEST dumpfile=test.dmp exclude=INDEX estimate=statistics
Estimate in progress using STATISTICS method...
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
. estimated "MH"."TEST" 54.86 KB ==>estimate=blocks時,估計為62 MB
Total estimation using STATISTICS method: 54.86 KB
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
. . exported "MH"."TEST" 52.45 MB 1000000 rows
Master table "SYS"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SYS.SYS_EXPORT_TABLE_01 is:
/home/oracle/mah/test.dmp
Job "SYS"."SYS_EXPORT_TABLE_01" successfully completed at 15:36:26
(2)包含索引匯出
[oracle@rhel5 mah]$ expdp \'sys/sys as sysdba\' directory='DMP_DIR' tables=MH.TEST dumpfile=test2.dmp estimate=statistics
Export: Release 10.2.0.1.0 - Production on Saturday, 15 March, 2014 15:37:22
Copyright (c) 2003, 2005, Oracle. All rights reserved.
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
Starting "SYS"."SYS_EXPORT_TABLE_01": 'sys/******** AS SYSDBA' directory=DMP_DIR tables=MH.TEST dumpfile=test2.dmp estimate=statistics
Estimate in progress using STATISTICS method...
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
. estimated "MH"."TEST" 54.86 KB
Total estimation using STATISTICS method: 54.86 KB
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/INDEX/INDEX
Processing object type TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
. . exported "MH"."TEST" 52.45 MB 1000000 rows
Master table "SYS"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SYS.SYS_EXPORT_TABLE_01 is:
/home/oracle/mah/test2.dmp
Job "SYS"."SYS_EXPORT_TABLE_01" successfully completed at 15:37:30
匯出檔案比較:
[oracle@rhel5 mah]$ ls -lrt
-rw-r----- 1 oracle oinstall 55070720 Mar 15 15:36 test.dmp
-rw-r----- 1 oracle oinstall 55078912 Mar 15 15:37 test2.dmp ==>含索引
==>兩個檔案大小差異極小(8192bytes),因TEST表上索引列較大(50bytes*1000000rows),不可能含索引資料;多出來的資料塊僅包含索引結構.
4匯入
(1)刪除表MH.TEST後:
impdp \'sys/sys as sysdba\' directory='DMP_DIR' tables=MH.TEST dumpfile=test.dmp
SQL> select table_name,num_rows,blocks,to_char(last_analyzed,'YYYYMMDD hh24miss') as l_anay from user_tables where table_name='TEST';
TABLE_NAME NUM_ROWS BLOCKS L_ANAY
---------- ---------- ---------- --------------------
TEST 1000 100 20140315 153457
SQL> select index_name,leaf_blocks,to_char(last_analyzed,'YYYYMMDD hh24miss') as l_anay from user_indexes where table_name='TEST';
no rows selected
(2)刪除表MH.TEST後:
impdp \'sys/sys as sysdba\' directory='DMP_DIR' tables=MH.TEST dumpfile=test2.dmp
SQL> select table_name,num_rows,blocks,to_char(last_analyzed,'YYYYMMDD hh24miss') as l_anay from user_tables where table_name='TEST';
TABLE_NAME NUM_ROWS BLOCKS L_ANAY
---------- ---------- ---------- --------------------
TEST 1000 100 20140315 153457
SQL> select index_name,leaf_blocks,to_char(last_analyzed,'YYYYMMDD hh24miss') as l_anay from user_indexes where table_name='TEST';
INDEX_NAME LEAF_BLOCKS L_ANAY
--------------- ----------- --------------------
IDX_TEST_X 100 20140315 153457
==>行數和資料塊是匯出時設定的統計資訊,而不是資料本身真實分佈資訊,包括索引和表上的上次分析時間
5結論
(1)expdp不匯出索引資料,僅匯出索引DDL
(2)expdp/impdp分別匯出/匯入統計資料
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/18922393/viewspace-719227/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 資料泵匯出匯入
- 資料泵的匯入匯出
- 資料泵匯出匯入表
- 資料泵匯出匯入資料標準文件
- Oracle資料泵-schema匯入匯出Oracle
- 使用資料泵工具expdp工具匯出資料
- 資料泵匯出資料包錯處理
- Oracle資料泵的匯入和匯出Oracle
- Oracle資料泵匯出匯入(expdp/impdp)Oracle
- Oracle使用資料泵匯出匯入表Oracle
- 資料泵取匯出和匯入(一)
- 資料泵避免個別表資料的匯出
- Oracle使用資料泵expdp,impdp進行資料匯出匯入Oracle
- Oracle expdp資料泵遠端匯出Oracle
- 使用資料泵匯出DDL語句
- 轉oracle資料泵匯出時報錯Oracle
- 資料庫泵(expdp/impdp)匯入匯出流程資料庫
- 資料泵過濾匯出資料的where條件
- 資料泵避免個別表資料的匯出(二)
- 使用資料泵impdp匯入資料
- 資料泵在本地匯出資料到遠端資料庫中資料庫
- 資料泵匯入分割槽表統計資訊報錯(七)
- 資料泵匯入分割槽表統計資訊報錯(二)
- 資料泵匯入分割槽表統計資訊報錯(四)
- 資料泵匯入分割槽表統計資訊報錯(三)
- 資料泵匯入分割槽表統計資訊報錯(六)
- 資料泵匯入分割槽表統計資訊報錯(五)
- Impdp資料泵匯入
- 12c 資料泵匯入匯出級別
- python實現oracle資料泵匯出功能PythonOracle
- oracle 資料泵匯出簡單使用版Oracle
- 利用資料泵匯出查詢結果(二)
- 利用資料泵匯出查詢結果(一)
- 細緻入微:如何使用資料泵匯出表的部分列資料
- 資料泵匯出匯入物化檢視(ORA-39083)
- oracle10G新特性之資料泵匯出/匯入Oracle
- 【匯入匯出】資料泵 job_name引數的使用
- shell,ant指令碼實現自動資料泵(exp.expdp)匯出匯入資料指令碼