In this task, you will use the RECOVER DATABASE command to restore the database to a specific point in time based on the recorded times from the previous task.
-
Prepare for Recovery:
Terminate active sessions and prepare the database for recovery.
db2 terminate
db2 force application all
Wait about 1 minute before performing the recover command to allow the database to shut down.
-
Recover the Database:
Use the RECOVER DATABASE command to restore the database to the recorded time of the first execution of the SQL script.
db2 recover database musicdb to yyyy-mm-dd-hh.mm.ss
-
Verify Recovery:
Connect to the database and check the row count in the TEMP_STOCK table to verify recovery.
db2 connect to musicdb
db2 "select count(*) from music.temp_stock"
db2 terminate
Ensure that the recovery target time value is specified correctly in the format yyyy-mm-dd-hh.mm.ss.
By completing this task, you have successfully recovered the database to a specific point in time, verifying the recovery by checking the row count in the TEMP_STOCK table.