[20150707]資料泵造成的資料損失.txt
[20150707]資料泵造成的資料損失.txt
--參看連結,重複測試
SCOTT@test> @ver1
PORT_STRING VERSION BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx 11.2.0.3.0 Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
CREATE TABLE T_PART PARTITION BY RANGE (CREATED)
(PARTITION P1 VALUES LESS THAN (TO_DATE('2012-1-1', 'YYYY-MM-DD')),
PARTITION P2 VALUES LESS THAN (TO_DATE('2012-2-1', 'YYYY-MM-DD')),
PARTITION P3 VALUES LESS THAN (TO_DATE('2012-3-1', 'YYYY-MM-DD')),
PARTITION P4 VALUES LESS THAN (TO_DATE('2012-4-1', 'YYYY-MM-DD')),
PARTITION PMAX VALUES LESS THAN (MAXVALUE))
AS SELECT * FROM DBA_OBJECTS;
SCOTT@test> select count(*) from t_part partition (p4);
COUNT(*)
----------
31
SCOTT@test> select count(*) from t_part partition (p3);
COUNT(*)
----------
9
SCOTT@test> select count(*) from t_part partition (pmax);
COUNT(*)
----------
10005
SCOTT@test> select count(*) from t_part partition (p1);
COUNT(*)
----------
67590
SCOTT@test> select count(*) from t_part partition (p2);
COUNT(*)
----------
115
$ expdp scott/btbtms directory=DATA_PUMP_DIR dumpfile=t_part.dmp logfile=t_part.log tables=t_part:p3,t_part:p4
Export: Release 11.2.0.3.0 - Production on Tue Jul 7 09:00:25 2015
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "SCOTT"."SYS_EXPORT_TABLE_01": scott/a****** directory=DATA_PUMP_DIR dumpfile=t_part.dmp logfile=t_part.log tables=t_part:p3,t_part:p4
Estimate in progress using BLOCKS method...
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 16 MB
Processing object type TABLE_EXPORT/TABLE/TABLE
. . exported "SCOTT"."T_PART":"P3" 11.49 KB 9 rows
. . exported "SCOTT"."T_PART":"P4" 13.89 KB 31 rows
Master table "SCOTT"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SCOTT.SYS_EXPORT_TABLE_01 is:
/u01/app/oracle11g/admin/test/dpdump/t_part.dmp
Job "SCOTT"."SYS_EXPORT_TABLE_01" successfully completed at 09:00:50
$ impdp scott/btbtms directory=DATA_PUMP_DIR dumpfile=t_part.dmp logfile=t_part_imp.log tables=t_part:p3 table_exists_action=replace
Import: Release 11.2.0.3.0 - Production on Tue Jul 7 09:02:15 2015
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Master table "SCOTT"."SYS_IMPORT_TABLE_01" successfully loaded/unloaded
Starting "SCOTT"."SYS_IMPORT_TABLE_01": scott/a******* directory=DATA_PUMP_DIR dumpfile=t_part.dmp logfile=t_part_imp.log tables=t_part:p3 table_exists_action=replace
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
. . imported "SCOTT"."T_PART":"P3" 11.49 KB 9 rows
Job "SCOTT"."SYS_IMPORT_TABLE_01" successfully completed at 09:02:20
雖然匯入的時候僅指定了一個分割槽,但是Oracle並不會對這一個分割槽執行TRUNCATE操作,而是將整個表DROP掉,然後利用資料泵中的源數
據重建。
SCOTT@test> select count(*) from t_part partition (p1);
COUNT(*)
----------
0
SCOTT@test> select count(*) from t_part partition (p2);
COUNT(*)
----------
0
SCOTT@test> select count(*) from t_part partition (p3);
COUNT(*)
----------
9
SCOTT@test> select count(*) from t_part partition (p4);
COUNT(*)
----------
0
SCOTT@test> select count(*) from t_part partition (pmax);
COUNT(*)
----------
0
這個表中只有匯入的分割槽記錄存在,原則上impdp對應的資料泵匯出檔案中的記錄也都是可以恢復的,但是表中其他的分割槽資料則完全丟
失。
而且Oracle在刪除的時候還使用PURGE選項,使得分割槽表在刪除的時候並沒有被放到回收站中,而是直接從資料庫中被清除。從這一點上
講,Oracle應該去掉PURGE語句,或者至少給出一個選項,畢竟DROP TABLE對於系統來說有風險的。
--比較正確的做法是:
SCOTT@test> delete from t_part partition(p3);
9 rows deleted.
SCOTT@test> commit ;
Commit complete.
$ impdp scott/btbtms directory=DATA_PUMP_DIR dumpfile=t_part.dmp logfile=t_part_imp.log tables=t_part:p3 table_exists_action=append
Import: Release 11.2.0.3.0 - Production on Tue Jul 7 09:15:25 2015
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Master table "SCOTT"."SYS_IMPORT_TABLE_01" successfully loaded/unloaded
Starting "SCOTT"."SYS_IMPORT_TABLE_01": scott/a******* directory=DATA_PUMP_DIR dumpfile=t_part.dmp logfile=t_part_imp.log tables=t_part:p3 table_exists_action=append
Processing object type TABLE_EXPORT/TABLE/TABLE
Table "SCOTT"."T_PART" exists. Data will be appended to existing table but all dependent metadata will be skipped due to table_exists_action of append
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
. . imported "SCOTT"."T_PART":"P3" 11.49 KB 9 rows
Job "SCOTT"."SYS_IMPORT_TABLE_01" successfully completed at 09:15:31
SCOTT@test> select count(*) from t_part partition (p4);
COUNT(*)
----------
31
SCOTT@test> select count(*) from t_part partition (p1);
COUNT(*)
----------
67590
SCOTT@test> select count(*) from t_part partition (p2);
COUNT(*)
----------
115
SCOTT@test> select count(*) from t_part partition (p3);
COUNT(*)
----------
9
SCOTT@test> select count(*) from t_part partition (pmax);
COUNT(*)
----------
10005
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-1725204/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 資料泵造成的資料損失
- [20150729]資料泵造成的資料損失2.txt
- 【北亞資料恢復】企業如何避免伺服器資料丟失造成重大損失?資料恢復伺服器
- 刪除資料泵備份失敗的表
- 資料泵
- 資料檔案損壞、丟失
- Oracle資料恢復:強制Resetlogs的可能資料損失Oracle資料恢復
- 資料泵的使用
- Redis 的 KEYS 命令引起 RDS 資料庫雪崩,當機 2 次,造成幾百萬損失Redis資料庫
- ORACLE 資料泵Oracle
- oracle資料泵Oracle
- 資料檔案丟失損壞的恢復--
- Oracle 資料泵的使用Oracle
- 陣列櫃故障造成控制檔案損壞,資料檔案損壞陣列
- 資料庫升級之-資料泵資料庫
- 使用資料泵impdp匯入資料
- 殺停資料泵
- oracle 資料泵解析Oracle
- 資料泵 impdp 操作
- 資料泵檔案
- 資料泵小bug
- oracle之資料泵Oracle
- 海量資料處理_資料泵分批資料遷移
- 資料泵引數檔案用於執行資料泵命令
- 資料泵避免個別表資料的匯出
- 【北亞資料恢復】誤操作分割槽損壞導致SqlServer資料庫資料丟失的資料恢復資料恢復SQLServer資料庫
- Impdp資料泵匯入
- oracle 資料泵引數Oracle
- 資料泵用法筆記筆記
- 資料泵過濾匯出資料的where條件
- 對資料泵資料傳輸的時間統計
- 資料泵避免個別表資料的匯出(二)
- Oracle資料庫(資料泵)遷移方案(上)Oracle資料庫
- Oracle資料庫(資料泵)遷移方案(下)Oracle資料庫
- 使用資料泵工具expdp工具匯出資料
- 【移動資料】data pump(上) 資料泵概述
- 資料泵匯出資料包錯處理
- 資料庫遷移之資料泵實驗資料庫