1、还原数据库
db2 restore db dc from /db2_backup/dc taken at 20121102142900 with 1 buffers buffer 256
2、回滚数据库,1>和2>只执行其一。
1>、作用是将数据库回滚到最新日志时间
db2 rollforward db dc to end of logs and stop
2>、作用将数据库回滚到指定时间
db2 rollforward db dc to 2012-11-08-14.05.27 using local time
3、完成数据库回滚
db2 rollforward db dc stop
4、下面是一个还原数据库并进行回滚的一个例子。
$ db2stop force
SQL1064N DB2STOP processing was successful.
$ db2start
SQL1063N DB2START processing was successful.
$ db2 restore db dc from /db2_backup/dc taken at 20121102142900 with 1 buffers buffer 256
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.
$ db2 connect to dc user admin using admin
SQL1117N A connection to or activation of database "DC" cannot be made
because of ROLL-FORWARD PENDING. SQLSTATE=57019
$ db2 rollforward db dc to 2012-11-08-19.09.27 using local time
&nbs

本文详细介绍了如何在DB2数据库中进行回滚操作,包括如何使用db2 restore命令还原数据库,以及如何通过db2 rollforward命令将数据库回滚到特定时间点。通过具体的步骤演示了从备份恢复数据库并进行回滚的全过程。
最低0.47元/天 解锁文章
32





