How AUL/MyDUL recover the rows truncated by mistake?
Some people truncated there tables by mistake, and asked for how to recover the data on BBS. Here is the AUL/MyDUL solution for this case. Let's start with building a test table:
ASQL> DESC TRUNCDEMO
NO# NAME NULLABLE TYPE
--- ----------------- -------- ------------
1 COL1 VARCHAR2(20)
ASQL> SELECT * FROM TRUNCDEMO;
COL1
-----
ROW 1
ROW 2
2 rows returned.
Then we truncate the table, actually this operation just format the segment header, assign a new data object id, and change the extent allocation information, if truncate with reuse storage operation, extent allocate information will not be changed. Let's check the data object id before and after the operation:
ASQL> SELECT DATA_OBJECT_ID, OBJECT_NAME FROM USER_OBJECTS;
DATA_OBJECT_ID OBJECT_NAME
-------------- -----------
13676 TRUNCDEMO
1 rows returned.
ASQL> truncate table truncdemo;
Truncate Table Succeed.
ASQL> SELECT DATA_OBJECT_ID, OBJECT_NAME FROM USER_OBJECTS;
DATA_OBJECT_ID OBJECT_NAME
-------------- -----------
13677 TRUNCDEMO
1 rows returned.
Because of system have lost the information before truncation of the table, so it could be treated as lost system tablespace. In the following example, we found that we could specify the data object id before truncation to recover the rows, by the new data object id we cannot recover the rows. If the freed space have been reused by other objects or newly inserted rows, nothing could be recovered.
