Standard reference from: http://www.xifenfei.com/1527.html
Objective: To change the SCN information of DataFile 5 which has been offline to be consistent with other datafile.
DB version is 11.2.0.4
Background knowledge:
1. The file header of datafile is stored in the first block.
2. Oracle considers four attributes of this data structure when determining if a datafile are sync with the other data files of the database: (different versions of the Oracle version of offset may be different)
(1) Kscnbas (at offset 140) –scn of the datafile.
(2) Kcvcptim (at offset 148)-time of the last change to the datafile.
(3) KCVFHCPC (at offset 176) –checkpoint count.
(4) KCVFHCCC (at offset 184) –unknown, but was always 1 less than Thecheckpoint point count.
Oracle has 4 properties to determine if datafile and other datafile are consistent, if they are consistent, can be normal operation, if not consistent, then reported ORA-01113 error
the contents of bbed Password=blockedit blocksize=8192 listfile=/home/oracle/bbed.file mode=edit/home/oracle/bbed.file are as follows: 1 /U01/APP/ORACLE/ORADATA/TEST/SYSTEM01.DBF 8493465602/u01/app/oracle/oradata/test/sysaux01.dbf 34707865603/u01/ APP/ORACLE/ORADATA/TEST/UNDOTBS01.DBF 2516582404/u01/app/oracle/oradata/test/users01.dbf 3827302405/u01/app/ ORACLE/ORADATA/TEST/TEN01.DBF 524288006/u01/app/oracle/oradata/test/tb_test_01.dbf 52428807/u01/app/oracle/ ORADATA/TEST/TS1.DBF 5242880008/u01/app/oracle/oradata/test/ts2.dbf 5242880009/u01/app/oracle/oradata/test/ TEST01.DBF 5242880010/u01/app/oracle/oradata/test/test_uni_sz_2m_01.dbf 5242880011/u01/app/oracle/oradata/test/ TEST_UNI_SZ_1M_01.DBF 20971520012/u01/app/oracle/oradata/test/test.dbf 10485760
As above, you can use the following statement to generate:
Select File#| | ' '|| name| | ' '|| bytes from V$datafile;
Bbed> Set DBA 0x00400001 dba (4194305) bbed> p kcvfhckpstruct kcvfhckp, bytes @484 struct KCVCPSCN, 8 bytes @484 ub4 kscnbas @484 0X0036B5C8---> ub2 kscnwrp @488 0x0000 ub4 Kcvcptim @492 0x344bc95d---> UB2 kcvcpthr @496 0x0001 Union u, bytes @500 struct Kcvcprba, bytes @500 ub4 kcrbaseq @500 0x00000001 ub4 kcrbabno @504 0x000021e7 ub2 kcrbabof @508 0x0010 ub1 kcvcpetb[0] @512 0x02 ub1 kcvcpetb[1] @5 0x00 ub1 kcvcpetb[2] @514 0x00 ub1 kcvcpetb[3] @515 0x00 Ub1 Kcvcpetb[4] @516 0x00 ub1 kcvcpetb[5] @517 0x00 ub1 kcvcpetb[6] @518 0x00 ub1 kcvcpetb[7] @519 0x00bbed> p kcvfhcpcub4 KCVFHC PC @140 0x00000168--->BBED> p kcvfhcccub4 kcvfhccc @148 0x00000167--->
Bbed> Set DBA 5,1 dba 0x01400001 (20971521 5,1) bbed> p kcvfhckpstruct Kcvfhckp, by TES @484 struct KCVCPSCN, 8 bytes @484 ub4 kscnbas @484 0x00369818---> ub2 kscnwrp @488 0x0000 ub4 Kcvcptim @492 0x344b98b3---> UB2 kcvcpthr @496 0x0001 Union u, bytes @500 struct Kcvcprba, bytes @500 ub4 kcrbaseq @500 0x00000098 ub4 kcrbabno @504 0x0000b62c ub2 kcrbabof @508 0x0010 ub1 kcvcpetb[0] @512 0x02 ub1 kcvcpetb[1] @513 0x00 ub1 kcvcpetb[2] @514 0x00 ub1 kcvcpetb[3] @515 0x00 Ub1 KCVCPETB[4] @516 0x00 ub1 kcvcpetb[5] @517 0x00 ub1 KCVCP ETB[6] @518 0x00 ub1 kcvcpetb[7] @519 0x00bbed> p KCVFHCP CUB4 KCVFHCPC @140 0x00000104--->BBED> p kcvfhcccub4 kcvfhccc @148 0x00000103--->
======================================================================================
The following changes are started:
Bbed> Set DBA 5,1 dba 0x01400001 (20971521 5,1) bbed> m/x c8b53600 offset 484bbed-00209:invalid Number (c8b53600) bbed> m/x c8b5 File:/u01/app/oracle/oradata/test/ten01.dbf (5) Block:1 offsets:484 To 487 dba:0x01400001------------------------------------------------------------------------c8b53600 <32 Bytes per line>bbed> set Offset +2 offset 486bbed> m/x 3600 File:/u01/app/oracle/oradata/test/ TEN01.DBF (5) block:1 offsets:486 to 489 dba:0x01400001-------------------------------------- ----------------------------------36000000 <32 bytes per line>bbed> m/x 5dc94b34 offset 492 File:/u01/app/ora CLE/ORADATA/TEST/TEN01.DBF (5) block:1 offsets:492 to 495 dba:0x01400001--------------------- ---------------------------------------------------5dc94b34 <32 bytes per line>bbed> m/x 68010000 offset + F Ile:/u01/app/oracle/oraDATA/TEST/TEN01.DBF (5) Block:1 offsets:140 to 143 dba:0x01400001---------------------------- --------------------------------------------68010000 <32 bytes per line>bbed> m/x 67010000 offset 148 File:/u 01/APP/ORACLE/ORADATA/TEST/TEN01.DBF (5) block:1 offsets:148 to 151 dba:0x01400001----------- -------------------------------------------------------------67010000 <32 bytes per line>bbed> p Kcvfhckpstruct kcvfhckp, Bytes @484 struct KCVCPSCN, 8 bytes @484 UB 4 Kscnbas @484 0x0036b5c8 ub2 kscnwrp @488 0x0000 ub4 Kcvcptim @492 0x344bc95d ub2 kcvcpthr @496 0x0001 u Nion u, bytes @500 struct kcvcprba, bytes @500 ub4 kcrbase Q @500 0x00000098 ub4 kcrbabno @504 0x0000b62c ub2 kcrbabof @508 0x0010 ub1 kcvcpetb[0] @512 0x02 ub1 kcvcpetb[1] @513 0 X00 ub1 kcvcpetb[2] @514 0x00 ub1 kcvcpetb[3] @515 0x00 Ub1 kcvcpetb[4] @516 0x00 ub1 kcvcpetb[5] @517 0x00 ub1 KC VCPETB[6] @518 0x00 ub1 kcvcpetb[7] @519 0x00bbed> p KCVF HCPCUB4 kcvfhcpc @140 0x00000168bbed> p kcvfhcccub4 KCVFHCCC @148 0x00000167bbed> Sumcheck value for File 5, Block 1:current = 0xc16c, required = 0xbd5abbed> sum a Pplycheck value for File 5, Block 1:current = 0xbd5a, required = 0xbd5abbed>
Sql> Select File#,to_char (checkpoint_change#, ' 999999999999 '), To_char (resetlogs_change#, ' 999999999999 ') from v$ Datafile_header; 2 file# to_char (CHECK to_char (RESET-------------------------------1 3585483 3580553 2 3585483 3580553 3 3585483 3580553 4 3585483 3580553 5 3585480 995548--- >3585480 and 3585483 are not the same. 6 3585483 3580553 7 3585483 3580553 8 3585483 3580553 9 3585483 3 580553 3585483 3580553 3585483 3580553, 3395372 99554812 rows selected. sql> recover datafile 5;--->recover is not a drop because the datafile is a data file resetlog the offline session before Ora-00283:recovery Canceled due to Errorsora-19909:datafile 5 belongs to an orphan Incarnationora-01110:data file 5: '/u01/app/oracle/orada TA/TEST/TEN01.DBF '
Purpose: Use bbed to change the SCN information for DataFile 5 that has been offline to be consistent with other datafile.