Data loss caused by database misoperation is a common data loss situation , Usually, after the data is deleted by mistake, the backup data can be restored , Then it does not rule out that database backup cannot be used in some special cases 、 Restore error, etc , What I'm going to tell you today is a real example oracle Database error truncate table After the database recovery process , If the backup just can't be used after misoperation, you can refer to the following recovery fee scheme .
First of all Truncate How it works : Under normal circumstances oracle Will pass Segment_Header And data dictionary to table Data_Object_ID updated , The block specific to the part where the data is stored is not actually modified , So in oracle When the service reads the full table data again, the data dictionary and Data_Object_ID It is inconsistent with the content of the data block actually stored and will not be read truncate Record the content of , This is the key to database recovery .
Data recovery process
In this case demonstration , The data recovery engineer constructed one of the above failures . The parameters of the hardware and software equipment to construct the fault are as follows :
Os:win server 2008R2.
Database version :win_oracle_11.2.0.1_x64;
First Scott Users create tables emp1, Copy emp surface , Copy many times in succession , The total number of records is :7340032 strip . And then truncate surface emp1. At this point, query the table , The record of this table in the database is 0 strip . See Figure 1 below :
1 Open the underlying data of the database file , Yes system Table space file analysis , find truncate The location of the table's original data , As shown in Figure 2 :
2 The data file database where the parsing table is located , find truncate The data of
3 take truncate Is inserted into the database
Data recovery results
Through analysis system01.dbf file , find truncate The location of the data for , Find the deleted data . The data file where the parsing table is located , take truncate The data is inserted into the database .
In the database , Find by truncate, The data is back , Back up data directly . As shown in Figure 3 :
Exp export scott user ; As shown in Figure 4 :