---
title: "Oracle 不完全恢复命令在数据文件头修改了什么？"
author: "itspace"
date: "2011-10-13T12:29:36Z"
tags: []
categories: ["数据库"]
slug: "oracle"
draft: false
lastmod: "2011-10-13T12:33:06Z"
id: 1194402
url: "https://dbzone.iteye.com/blog/1194402"
---

有时候我们经常碰到如下情况：
SQL> alter database open read only;
alter database open read only
*
ERROR at line 1:
ORA-01122: database file 1 failed verification check
ORA-01110: data file 1: '/lank/db/lank/system01.dbf'
ORA-01207: file is more recent than control file - old control file
但是检查数据文件头和控制文件头的checkpoint change和checkpoint count均处于一致状态，只有当发起如下命令之后，但并没有真正应用日志，数据库才能open read only。
SQL> recover database using backup controlfile until cancel;
ORA-00279: change 10999733114786 generated at 10/13/2011 09:30:32 needed for
thread 1
ORA-00289: suggestion : /lank/db/arch/1_45_762364447.dbf
ORA-00280: change 10999733114786 for thread 1 is in sequence #45


Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
cancel
Media recovery cancelled.
SQL> alter database open read only;

Database altered.

经过后台跟踪发现，原来数据库要read only或者read write打开，仅仅数据文件头和控制文件头的checkpoint change和checkpoint count均处于一致状态是不够的，还需要控制文件头的control seq大于数据文件头的control seq，而until cancel正是将数据文件头的control seq重置为0。
ub4 kccfhcsq                          @40       0x00000001
另外Oracle还会在数据文件头144号位置修改，但此处可以忽略
ub4 kcvfhrts                             @144      0x2d901a51
重置为0之后，需要注意的是数据库需要resetlogs打开了。