Chapter 26. DBMS_REPAIR

Table of Contents

26.1. Overview
26.2. Functions
26.2.1. ONLINE_INDEX_CLEAN

This chapter briefly introduces the DBMS_REPAIR package, and describes how to use the functions of the package.

26.1. Overview

DBMS_REPAIR is used to check for and repair data block corruption in a table or an index.

The following are constants defined in the DBMS_REPAIR package:

  • ALL_INDEX_ID

    Specifies a schema object ID to clean up all indexes.

    ALL_INDEX_ID CONSTANT BINARY_INTEGER := 0
  • LOCK_NOWAIT

    Requests DML lock on dependent tables, partitions, or subpartitions in NOWAIT mode.

    LOCK_NOWAIT CONSTANT BOOLEAN := true
  • LOCK_WAIT

    Requests DML lock on dependent tables, partitions, or subpartitions in WAIT mode.

    LOCK_NOWAIT CONSTANT BOOLEAN := false

26.2. Functions

This section describes the functions provided by the DBMS_REPAIR package.

26.2.1. ONLINE_INDEX_CLEAN

Cleans up failed or suspended index online-builds or online-rebuilds.

Details about the ONLINE_INDEX_CLEAN function are as follows:

  • Prototype

    DBMS_REPAIR.ONLINE_INDEX_CLEAN
    (
        object_id       IN  BINARY_INTEGER  DEFAULT ALL_INDEX_ID,
        wait_for_lock   IN  BOOLEAN         DEFAULT LOCK_WAIT
    )  
    RETURN BOOLEAN;
  • Parameter

    ParameterDescription
    object_id

    Schema object ID of the index to clean up.

    If set to ALL_INDEX_ID, all qualified object IDs are cleaned.

    wait_for_lock

    The LOCK mode used to request DML locks on index-dependent tables, partitions, or subpartitions.

    • If set to LOCK_NOWAIT and getting the lock fails, the cleanup is immediately stopped.

    • If set to LOCK_WAIT, an attempt to get the lock is repeated until successful.

  • Return Value

    ValueDescription
    TRUEReturned if all indexes have been cleaned up.
    FALSEReturned if one or more indexes have failed to be not cleaned up.
  • Example

    DECLARE
        cleaned BOOLEAN;
    BEGIN
        cleaned := false;
        WHILE cleaned = false
        LOOP
            cleaned := DBMS_REPAIR.ONLINE_INDEX_CLEAN(DBMS_REPAIR.ALL_INDEX_ID,
                                                   DBMS_REPAIR.LOCK_WAIT);
            DBMS_LOCK.SLEEP(10);
        END LOOP;
    EXCEPTION
        WHEN OTHERS THEN
        RAISE;
    END;
    /
    
    PSM completed
    SQL>