我有一张桌子
EMPLOYEE.EMPLOYEE
内部数据库
HELLO
其中包含3条记录,如下所示:
EMP_NO BIRTH_DATE FIRST_NAME LAST_NAME GENDER HIRE_DATE BANK_ACCOUNT_NUMBER PHONE_NUMBER
------- ---------- ------------------ -------------------- ------ ---------- ------------------- --------------
1. 06/05/1998 A B M 01/02/2019 026201521420 +91X
2. 10/14/1997 C D M 01/07/2019 034212323454 +91Y
3. 05/27/1997 E F F 01/14/2019 92329323123 +91Z
然后我首先使用以下命令进行脱机备份
mkdir offlinebackup
db2 terminate
db2 deactivate database HELLO
db2 backup database HELLO to ~/offlinebackup/
然后我得到这个输出:
Backup successful. The timestamp for this backup image is : 20190128115210
现在我使用以下命令进行联机备份
db2 update database configuration for HELLO using LOGARCHMETH1 'DISK:/database/config/db2inst1/onlinebackup'
db2 backup database HELLO online to /database/config/db2inst1/onlinebackup compress include logs
在此之后,我得到输出为:
Backup successful. The timestamp for this backup image is : 20190128115616
现在我回到DB2并运行
CONNECT TO HELLO
它将我连接到我的数据库。当我检查
雇员.雇员
桌上,我还有三排。
现在我删除了EMP_3的行。这将被成功删除。然后我跑
quit
从DB2终端
然后我使用此命令从脱机备份运行还原:
db2 restore db HELLO from ~/offlinebackup/ replace existing
它说
DB20000I The RESTORE DATABASE command completed successfully
现在我试着连接到Hello,它说
SQL1117N A connection to or activation of database "HELLO" cannot be made because of ROLL-FORWARD PENDING. SQLSTATE=57019
我运行
db2 rollforward db HELLO to end of logs and stop
然后我连接到hello并尝试找出行,我只得到2行,而不是3行,因为它在备份中。
EMP_NO BIRTH_DATE FIRST_NAME LAST_NAME GENDER HIRE_DATE BANK_ACCOUNT_NUMBER PHONE_NUMBER
------- ---------- ------------------ --------------------- ------ ---------- ------------------- --------------
1. 06/05/1998 A B M 01/02/2019 026201521420 +91X
2. 10/14/1997 C D M 01/07/2019 034212323454 +91Y
第三条记录不可见,它出现在备份中。有人能知道为什么我不能从备份中恢复第三个记录吗