Thursday, January 31, 2013

ORA-01200


Sometimes when you try to start a database, you may get ORA-01200 error like:

ORA-01122: database file 8 failed verification check
ORA-01110: data file 8: '/bitest/oradata/bitest/cists02.dbf'

ORA-01200: actual file size of 64000 is smaller than correct size of 416256 blocks



The best solution is restore if you have a backup.
However if you don't have a backup, you can try to make the datafile have same block sizes registered in the control file to cheat oracle, but you may face data loses.

Steps as below (Caution: use at your own risk!!)

[bitest] /home/oracle >sqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Wed Jan 30 16:01:17 2013

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> startup
ORACLE instance started.

Total System Global Area 6413680640 bytes
Fixed Size                  2233480 bytes
Variable Size            1090521976 bytes
Database Buffers         5251268608 bytes
Redo Buffers               69656576 bytes
Database mounted.
ORA-01122: database file 8 failed verification check
ORA-01110: data file 8: '/bitest/oradata/bitest/cists02.dbf'
ORA-01200: actual file size of 64000 is smaller than correct size of 416256
blocks


SQL> shutdown immediate
ORA-01109: database not open


Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.

Total System Global Area 6413680640 bytes
Fixed Size                  2233480 bytes
Variable Size            1090521976 bytes
Database Buffers         5251268608 bytes
Redo Buffers               69656576 bytes
Database mounted.
SQL>

SQL> show parameter db_block_size

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_block_size                        integer     8192


SQL> !ls -lrt /bitest/oradata/bitest/cists02.dbf
-rw-r-----    1 oracle   dba       524296192 Jan 30 15:43 /bitest/oradata/bitest/cists02.dbf

SQL> select (524296192-8192)/8192 from dual;

(524296192-8192)/8192
---------------------
                64000

Actual file has 64000 blocks.

SQL> select bytes from v$datafile where name='/bitest/oradata/bitest/cists02.dbf';

     BYTES
----------
3409969152

SQL> select 3409969152/8192 from dual;

3409969152/8192
---------------
         416256

Control file indicates the file should have 416256 blocks.

If you have a backup, you can just simply restore from the backup.
Another way to cheat oracle is to make the actual file has the same blocks registered in the control file.


SQL> select 416256-64000 from dual;

416256-64000
------------
      352256

SQL> ! dd if=/dev/zero of=/bitest/oradata/bitest/cists02.dbf bs=8192 count=352256 seek=64001

SQL> !ls -lrt /bitest/oradata/bitest/cists02.dbf
-rw-r-----    1 oracle   dba      3409977344 Jan 30 16:11 /bitest/oradata/bitest/cists02.dbf

SQL> select (3409977344-8192)/8192 from dual;

(3409977344-8192)/8192
----------------------
                416256

SQL> alter database open;

Database altered.

No comments:

Post a Comment