db2 表被誤刪(drop)
確定開啟歸檔
確認表空間為drop_recovery
--確認表空間是drop_recovery的狀態
select tbspace ,drop_recovery from syscat.tablespaces;
--若不是,可以使用以下語句開啟
alter tablespace tablespace_name dropped table recovery on
[db2inst2@baktest130 shell]$ ./cms_backup_online.sh
Backup successful. The timestamp for this backup image is : 20150624140258
db2 => select count(1) from testa
1
-----------
1525
1 record(s) selected.
db2 => select count(1) from testb
1
-----------
1525
1 record(s) selected.
db2 => select count(1) from testc
SQL0204N "DB2INST2.TESTC" is an undefined name. SQLSTATE=42704
db2 => create table testc like testa
DB20000I The SQL command completed successfully.
db2 => insert into testc select * from testa
DB20000I The SQL command completed successfully.
db2 => commit
DB20000I The SQL command completed successfully.
db2 => list history dropped table all for cms
List History File for cms
Number of matching file entries = 10
Op Obj Timestamp+Sequence Type Dev Earliest Log Current Log Backup ID
-- --- ------------------ ---- --- ------------ ------------ --------------
D T 20150624142536 00000000e90015420002080f
----------------------------------------------------------------------------
"DB2INST2"."TESTA" resides in 1 tablespace(s):
00001 USERSPACE1
----------------------------------------------------------------------------
Comment: DROP TABLE
Start Time: 20150624142536
End Time: 20150624142536
Status: A
----------------------------------------------------------------------------
EID: 934
DDL: CREATE TABLE "DB2INST2"."TESTA" ( …… ) IN "USERSPACE1" ;
檢視backup id
開始恢復誤刪的表testa
[db2inst2@baktest130 backup_dir]$ db2 restore db cms taken at 20150624140258
SQL2539W Warning! Restoring to an existing database that is the same as the
backup image database. The database files will be deleted.
Do you want to continue ? (y/n) y
DB20000I The RESTORE DATABASE command completed successfully.
[db2inst2@baktest130 backup_dir]$ db2 "rollforward db cms to end of logs and stop recover dropped table 00000000e90015420002080f to /home/db2inst2"
Rollforward Status
Input database alias = cms
Number of nodes have returned status = 1
Node number = 0
Rollforward status = not pending
Next log file to be read =
Log files processed = S0000565.LOG - S0000566.LOG
Last committed transaction = 2015-06-24-14.25.37.000000 Local
DB20000I The ROLLFORWARD command completed successfully.
檢視在指定目錄下 /home/db2inst2 下新建了一個NODE0000資料夾,其下有個data檔案
此時檢視,testc表存在,testa不存在
db2 => select count(1) from testc
1
-----------
1525
1 record(s) selected.
db2 => select count(1) from testa
SQL0204N "DB2INST2.TESTA" is an undefined name. SQLSTATE=42704
db2 =>
根據 db2 list history dropped table all for cms,檢視誤刪的表testa的表結構,重建testa表,然後將data檔案的內容import到testa中
--執行建立表testa後
db2 => select count(1) from testa
1
-----------
0
1 record(s) selected.
--import表
--由於未指定字符集,預設匯入後,有120條資料無法匯入,且中文字元為亂碼
db2 => import from /home/db2inst2/NODE0000/data of del insert into testa
SQL3149N "1525" rows were processed from the input file. "1405" rows were
successfully inserted into the table. "120" rows were rejected.
Number of rows read = 1525
Number of rows skipped = 0
Number of rows inserted = 1405
Number of rows updated = 0
Number of rows rejected = 120
Number of rows committed = 1525
--再次進行匯入,增加modified by codepage=1386,檢視匯入成功
[db2inst2@baktest130 backup_dir]$ db2 import from /home/db2inst2/NODE0000/data of del modified by codepage=1386 insert into testa
SQL3109N The utility is beginning to load data from file
"/home/db2inst2/NODE0000/data".
SQL3110N The utility has completed processing. "1525" rows were read from
the input file.
SQL3221W ...Begin COMMIT WORK. Input Record Count = "1525".
SQL3222W ...COMMIT of any database changes was successful.
SQL3149N "1525" rows were processed from the input file. "1525" rows were
successfully inserted into the table. "0" rows were rejected.
Number of rows read = 1525
Number of rows skipped = 0
Number of rows inserted = 1525
Number of rows updated = 0
Number of rows rejected = 0
Number of rows committed = 1525
codepage=1386 為GBK,1208 為UTF-8。
如果含有中文字元,可能需要設定字符集,否則可能匯入資料會出問題
db2的表誤刪或資料誤刪沒有Oracle靈活,短期內也可以使用閃回恢復。
對於誤刪資料(delete)大約需要將備份在異機還原,然後rollforward到指定時間點,再將相應的資料匯出、匯入
確認表空間為drop_recovery
--確認表空間是drop_recovery的狀態
select tbspace ,drop_recovery from syscat.tablespaces;
--若不是,可以使用以下語句開啟
alter tablespace tablespace_name dropped table recovery on
[db2inst2@baktest130 shell]$ ./cms_backup_online.sh
Backup successful. The timestamp for this backup image is : 20150624140258
db2 => select count(1) from testa
1
-----------
1525
1 record(s) selected.
db2 => select count(1) from testb
1
-----------
1525
1 record(s) selected.
db2 => select count(1) from testc
SQL0204N "DB2INST2.TESTC" is an undefined name. SQLSTATE=42704
db2 => create table testc like testa
DB20000I The SQL command completed successfully.
db2 => insert into testc select * from testa
DB20000I The SQL command completed successfully.
db2 => commit
DB20000I The SQL command completed successfully.
db2 => list history dropped table all for cms
List History File for cms
Number of matching file entries = 10
Op Obj Timestamp+Sequence Type Dev Earliest Log Current Log Backup ID
-- --- ------------------ ---- --- ------------ ------------ --------------
D T 20150624142536 00000000e90015420002080f
----------------------------------------------------------------------------
"DB2INST2"."TESTA" resides in 1 tablespace(s):
00001 USERSPACE1
----------------------------------------------------------------------------
Comment: DROP TABLE
Start Time: 20150624142536
End Time: 20150624142536
Status: A
----------------------------------------------------------------------------
EID: 934
DDL: CREATE TABLE "DB2INST2"."TESTA" ( …… ) IN "USERSPACE1" ;
檢視backup id
開始恢復誤刪的表testa
[db2inst2@baktest130 backup_dir]$ db2 restore db cms taken at 20150624140258
SQL2539W Warning! Restoring to an existing database that is the same as the
backup image database. The database files will be deleted.
Do you want to continue ? (y/n) y
DB20000I The RESTORE DATABASE command completed successfully.
[db2inst2@baktest130 backup_dir]$ db2 "rollforward db cms to end of logs and stop recover dropped table 00000000e90015420002080f to /home/db2inst2"
Rollforward Status
Input database alias = cms
Number of nodes have returned status = 1
Node number = 0
Rollforward status = not pending
Next log file to be read =
Log files processed = S0000565.LOG - S0000566.LOG
Last committed transaction = 2015-06-24-14.25.37.000000 Local
DB20000I The ROLLFORWARD command completed successfully.
檢視在指定目錄下 /home/db2inst2 下新建了一個NODE0000資料夾,其下有個data檔案
此時檢視,testc表存在,testa不存在
db2 => select count(1) from testc
1
-----------
1525
1 record(s) selected.
db2 => select count(1) from testa
SQL0204N "DB2INST2.TESTA" is an undefined name. SQLSTATE=42704
db2 =>
根據 db2 list history dropped table all for cms,檢視誤刪的表testa的表結構,重建testa表,然後將data檔案的內容import到testa中
--執行建立表testa後
db2 => select count(1) from testa
1
-----------
0
1 record(s) selected.
--import表
--由於未指定字符集,預設匯入後,有120條資料無法匯入,且中文字元為亂碼
db2 => import from /home/db2inst2/NODE0000/data of del insert into testa
SQL3149N "1525" rows were processed from the input file. "1405" rows were
successfully inserted into the table. "120" rows were rejected.
Number of rows read = 1525
Number of rows skipped = 0
Number of rows inserted = 1405
Number of rows updated = 0
Number of rows rejected = 120
Number of rows committed = 1525
--再次進行匯入,增加modified by codepage=1386,檢視匯入成功
[db2inst2@baktest130 backup_dir]$ db2 import from /home/db2inst2/NODE0000/data of del modified by codepage=1386 insert into testa
SQL3109N The utility is beginning to load data from file
"/home/db2inst2/NODE0000/data".
SQL3110N The utility has completed processing. "1525" rows were read from
the input file.
SQL3221W ...Begin COMMIT WORK. Input Record Count = "1525".
SQL3222W ...COMMIT of any database changes was successful.
SQL3149N "1525" rows were processed from the input file. "1525" rows were
successfully inserted into the table. "0" rows were rejected.
Number of rows read = 1525
Number of rows skipped = 0
Number of rows inserted = 1525
Number of rows updated = 0
Number of rows rejected = 0
Number of rows committed = 1525
codepage=1386 為GBK,1208 為UTF-8。
如果含有中文字元,可能需要設定字符集,否則可能匯入資料會出問題
db2的表誤刪或資料誤刪沒有Oracle靈活,短期內也可以使用閃回恢復。
對於誤刪資料(delete)大約需要將備份在異機還原,然後rollforward到指定時間點,再將相應的資料匯出、匯入
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/28258625/viewspace-1710731/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- oracle 誤刪表 drop tableOracle
- DB2 恢復誤刪除的表DB2
- Oracle 10g 中誤刪除(drop)表的恢復處理Oracle 10g
- DB2 批量刪除表DB2
- db2 恢復drop後的表的一個操作DB2
- 使用中undo表空間資料檔案被誤刪
- 【Flashback】使用Flashback Drop技術閃回被DROP表的指定版本資料
- 防刪庫實用指南 | 只需一步,快速召回被誤刪的表
- RMAN恢復單個表空間或被DROP/DELETE/TRUNCATE的表delete
- 刪除oracle表被鎖住Oracle
- [DB2]使用recover命令找回刪除的表DB2
- Oracle快速找回被刪除的表Oracle
- Oracle閃回誤刪的表Oracle
- Windows10應用商店被誤刪了怎麼辦 win10應用商店被誤刪如何找回WindowsWin10
- 被誤刪的檔案正確處理方法,快速找回誤刪的檔案
- 被誤刪的檔案快速恢復方法
- iptables配置資訊被誤刪瞭解決方法
- 【實戰】使用“基表修改法”恢復被“set unused”方式誤刪除的列
- 物化檢視日誌表被DROP後建立物化檢視報錯
- DB2 刪除DB2
- Mac上的照片被誤刪除怎麼辦?Mac
- UNDO表空間下的資料檔案被誤刪除後的處理方法
- 【實戰】使用“基表修改法”恢復被“set unused”方式誤刪除的列(續)
- mysql恢復drop表MySql
- 快速drop mysql大表MySql
- 表資料被誤操作的恢復
- Oracle恢復誤操作刪除掉的表Oracle
- win10中mdf檔案被誤刪如何恢復_win10系統mdf檔案被誤刪的恢復方法Win10
- DB2刪除schemaDB2
- 利用延時備庫找回被誤刪的資料
- Chrome書籤被誤刪後如何一鍵恢復Chrome
- Mac中Chrome書籤被誤刪後如何恢復MacChrome
- [Logmnr]使用logminer找回被誤刪的資料
- 使用logmnr分析歸檔日誌恢復被drop掉的資料表
- dual系統表被刪除的解決方法
- db2刪除已經儲存的表儲存過程DB2儲存過程
- 誤刪除dual表的解決辦法
- 函式儲存過程被誤刪恢復步驟函式儲存過程