Get the App
SLTechnology News&Howtos  ›  Database  › 

Use dbms_repair to mark and skip bad blocks

Shulou Source: shulou.com Published: 2022-06-01 05:02:12 10月30日 Update

SQL > select file_id, block_id, blocks from dba_extents where owner = 'LILC' and segment_name =' TEST';, 610624 1024 611648 102483 rows selected.

Destroy previous data:

SQL > select count (*) from test

COUNT (*)

-

783018

RMAN > recover datafile 6 block 11620 clear

RMAN > recover datafile 6 block 4467 clear

RMAN > backup check logical validate datafile 6

Starting backup at 23-SEP-15

Using channel ORA_DISK_1

Using channel ORA_DISK_2

Channel ORA_DISK_1: starting full datafile backup set

Channel ORA_DISK_1: specifying datafile (s) in backup set

Input datafile file number=00006 name=+DATA/phub/datafile/llc01.dbf

Channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07

List of Datafiles

=

File Status Marked Corrupt Empty Blocks Blocks Examined High SCN

-

6 FAILED 0 20 12800 1991935

File Name: + DATA/phub/datafile/llc01.dbf

Block Type Blocks Failing Blocks Processed

Data 2 12140

Index 0 329

Other 1 311

Validate found one or more corrupt blocks

See trace file / u01/app/oracle/diag/rdbms/phub/PHUB/trace/PHUB_ora_29666.trc for details

Finished backup at 23-SEP-15

The data query must have reported an error:

SQL > select count (*) from test

Select count (*) from test

*

ERROR at line 1:

ORA-01578: ORACLE data block corrupted (file # 6, block # 4467)

ORA-01110: datafile 6:'+ DATA/phub/datafile/llc01.dbf'

Skip_corrupt_blocks to skip the bad blocks:

SQL > exec dbms_repair.skip_corrupt_blocks (schema_name = > 'LILC',object_name = >' TEST',flags = > 1)

PL/SQL procedure successfully completed.

SQL > conn lilc/lilc

Connected.

SQL > select count (*) from test

COUNT (*)

-

782884

There are 34 pieces of data missing.

Repair bad block

RMAN > recover datafile 6 block 11620

2 >

Starting recover at 23-SEP-15

Using channel ORA_DISK_1

Using channel ORA_DISK_2

Finished standby search, restored 1 blocks

Starting media recovery

Media recovery complete, elapsed time: 00:00:01

Finished recover at 23-SEP-15

RMAN > recover datafile 6 block 4467

Starting recover at 23-SEP-15

Using channel ORA_DISK_1

Using channel ORA_DISK_2

Finished standby search, restored 1 blocks

Starting media recovery

Media recovery complete, elapsed time: 00:00:01

Finished recover at 23-SEP-15

The data is normal:

SQL > select count (*) from test

COUNT (*)

-

783018

Tags: Data data repair data query query affirmation tag Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia vpn OPPO Reno Docker MySQL