Welcome 微信登录

首页 / 数据库 / MySQL / Oracle数据字典一致性鉴别

数据字典(dd)一致性鉴别dd损坏通常包括:
1. Data Dictionary Inconsistency, missing rows in tables:
          - Tab$/Ind$ with no entries in OBJ$
          - Undo$/Tab$/Ind$ with no entries in SEG$
          - Seg$ with no entries in TAB$/IND$/OBJ$
tab$和ind$的条目在OBJ$中不存在;Undo$/Tab$/Ind$的条目在SEG$中不存在;Seg$的条目在TAB$/IND$/OBJ$中不存在
2. Missing data dictionary objects
DD对象丢失
3. Corrupted data dictionary objects (table, index, or table-index inconsistency)
DD对象损坏
4. Invalid entries in data dictionary tables.
DD表中存在无效对象1. Identifying Objects with Data Dictionary Inconsistency
 
首先需要安装hcheck包,参见Note136697.1
In order to detect data dictionary inconsistency we need to run hcheck.full procedure, see Note 136697.1.      a. Connect as SYS schema in sqlplus
      b. Create package hOut as described in Note 101468.1  先创建hOut包,该包主要用于控制hcheck系列程序的输出,见附件hout.sql
      c. Create package hcheck in SYS schema as described in Note 136697.1 attachment.
     d. set serveroutput on
      c. execute hcheck.fullThe script will report various dictionary related issues that may or may not be a problem.
Any problems reported should be reviewed by an experienced support analyst as some
reported "problems" may be normal and expected.
Example of HCHECK.FULL output:Problem: Orphaned IND$ (no SEG$) - See Note 65987.1 (Bug:624613/3655873) 
ORPHAN IND$: OBJ=200449 DOBJ=200449 TS=0 RFILE/BLOCK=0 0 BO#=200446 SegType= 
^- May be OK. Needs manual check
 ORPHAN IND$: OBJ=39442 DOBJ=39442 TS=14 RFILE/BLOCK=2 49 BO#=39438 SegType= Problem: Orphaned TAB$ (no SEG$) 
ORPHAN TAB$: OBJ=1817074 DOBJ=0 TS=0 RFILE/BLOCK=0 0 BOBJ#= SegType= 
^- May be OK. Needs manual check
 ORPHAN TAB$: OBJ=2149126 DOBJ=2149126 TS=19 RFILE/BLOCK=31 44291 BOBJ#= SegType=
 
Problem: Orphaned SEG$ Entry 
ORPHAN SEG$: SegType=INDEX TS=20 RFILE/BLOCK=33 28435
 
 
 
Based on the hcheck.full output you will have to identify the objects that show a dd inconsistency, and verify the reported inconsistency.
 Select name,type# from obj$ where obj#=<OBJ>; /* 1=INDEX, 2=TABLE, 3=CLUSTER, 21=LOB, 25=IOT
Select object_name,owner,object_type from dba_objects where object_id=<OBJ>;Some of the problems, mainly the one marked as  "May be OK. Needs manual check " could be a false alarm.
注意有些alarm未必是真的存在问题。
 
Check the type of the object.
 
Lob Index on temporary table or IOT do not have a segment, than the problem message is a false alarm.
例如:临时表的LOB索引或者IOT表的索引不存在段,但是hcheck会抛出一个alarm。
附:
1.hout.sql***Checked for relevance on 27-MAR-2013***
REM ======================================================================
REM hout.sql        Version 1.1    29 Dec 2000
REM
REM Purpose:
REM    To provide an output package for the h*.sql series of scripts.
REM   All h*.sql scripts use this package to output their results
REM    This allows one package to control where output is sent
REM    to.
REM    Eg: This package can be coded to output to DBMS_OUTPUT
REM        or to use the UTL_FILE calls if required.
REM
REM    This version of the script can write to both DBMS_OUTPUT and
REM    to the users trace file.
REM
REM Usage:
REM   See Note:101466.1 for details of using this and other h* packages
REM
REM Depends on:
REM    dbms_output , dbms_system
REM
REM Notes:
REM   Must be installed in SYS schema
REM    For Oracle 7.3, 8.0, 8.1, 9.0, 9.2, 10.1, 10.2, 11.1 and 11.2
REM   server versions
REM
REM CAUTION
REM The sample program in this article is provided for educational
REM purposes only and is NOT supported by Oracle Support Services. 
REM It has been tested internally, however, and works as documented. 
REM We do not guarantee that it will work for you, so be sure to test
REM it in your environment before relying on it.
REM
REM ======================================================================
REM
create or replace package hOut as
 --
 -- Output options - change these to default as required
 -- You can override them at run time if required.
 --
  TO_DBMS_OUTPUT boolean := TRUE;    -- Send output to DBMS_OUTPUT
  TO_USER_TRACE  boolean := TRUE;    -- Send output to user trace file
  IGNORE_ERRORS  boolean := TRUE;    -- Ignore DBMS_OUTPUT errors if
                    -- also writing to the trace file
 --
 -- Output methods
 --
  procedure put_line(txt varchar2);
  procedure put(txt varchar2);
  procedure new_line;
  procedure wrap(txt varchar2, linelen number default 78);
  procedure rule_off;
 --
end hOut;
/
show errors
create or replace package body hOut as
  -- 7.3 has problems with ksdwrt as it uses the wrong length info
  -- putting nonsense on the end of lines.
  -- As a workaround we copy the text to a TMP varchar, append a chr(0)
  -- then reset the length back so we have an hidden chr(0) at the end
  -- of the string.
  tmp varchar2(2001);
  --
  APP_EXCEPTION EXCEPTION;
  pragma exception_init(APP_EXCEPTION, -20000);
  --
  procedure put_line(txt varchar2) is
  begin
    tmp:=txt||chr(0);
    tmp:=txt;
    if TO_DBMS_OUTPUT then
      begin
    dbms_output.put_line(txt);
      exception
    when APP_EXCEPTION then
      -- If DBMS_OUTPUT is full then carry on if we are writing to
      -- the trace file and ignoring errors, otherwise error now
      if TO_USER_TRACE and IGNORE_ERRORS then
        begin
          dbms_output.put_line("[TRUNCATED]");
            exception
          when APP_EXCEPTION then
          null;
        end;
      else
        raise;
      end if;
      end;
    end if;
    if TO_USER_TRACE then
    dbms_system.ksdwrt(1,tmp);
    end if;
  end;
 --
  procedure put(txt varchar2) is
  begin
    tmp:=txt||chr(0);
    tmp:=txt;
    if TO_DBMS_OUTPUT then
      begin
    dbms_output.put(txt);
      exception
    when APP_EXCEPTION then
      -- If DBMS_OUTPUT is full then carry on if we are writing to
      -- the trace file and ignoring errors, otherwise error now
      if TO_USER_TRACE and IGNORE_ERRORS then
        begin
          dbms_output.put("[TRUNCATED]");
            exception
          when APP_EXCEPTION then
          null;
        end;
      else
        raise;
      end if;
      end;
    end if;
    if TO_USER_TRACE then
    dbms_system.ksdwrt(1,tmp);
    end if;
  end;
 --
  procedure new_line is
  begin
    if TO_DBMS_OUTPUT then
      begin
    dbms_output.new_line;
      exception
    when APP_EXCEPTION then
      if TO_USER_TRACE and IGNORE_ERRORS then
        null;
      else
        raise;
      end if;
      end;
    end if;
    if TO_USER_TRACE then
    dbms_system.ksdwrt(1," ");
    end if;
  end;
 --
  procedure wrap(txt varchar2, linelen number default 78) is
    p integer:=1;
    len integer;
    pos integer;
    chunk varchar2(2000);
    xchunk varchar2(2000);
    llen number:=linelen;
  BEGIN
    if (llen>2000) then
    llen:=2000;
    end if;
    if (llen<=1) then
    llen:=78;
    end if;
    len:=length(txt);
    while (p<=len) loop
      chunk:=substr(txt,p,llen);
      pos:=instr(chunk,chr(10),-1);
      if pos>0 then
     -- We have a CR in the text - use it
     put_line(substr(chunk,1,pos-1));
     p:=p+pos;
      else
     -- No CR in the text so we will look for a split character
     xchunk:=translate(chunk," ,()=",",,,,,");
     pos:=instr(xchunk,",",-1);
     if pos>0 and len>llen then
        put_line(substr(chunk,1,pos));
    p:=p+pos;
     else
        put(chunk);
    p:=p+llen;
     end if;
      end if;
    end loop;
    new_line;
  END;
 --
  procedure rule_off is
  begin
    put_line("=========================================================");
  end;
 --
begin
  dbms_output.enable(100000);
end hout;
/
REM ====================2.hcheck使用方法
SQL> set serveroutput on size unlimited
SQL> spool outputfile
SQL> execute hcheck.full 
SQL> spool off3.安装hcheck
先安装hOut,再安装hcheck2.sql(for 8i??不能运行于9I数据库)或hcheck3.sql(for 9i+)
4.hcheck3.sql
--
--------------------------------------------------------------------------
-- hcheck.sql          Version 3.50          Tue Mar 26 14:20:38 CEST 2013
--
-- Purpose:
-- To provide a single package which looks for common data dictionary
-- problems.
--   Note that this version has not been checked with locally managed
--   tablespaces and may give spurious output if these are in use.
--   This script is for use mainly under the guidance of Oracle Support.
--
-- Usage:
-- SQL> set serverout on size unlimited
-- SQL> exec hcheck.full [(parameters)]
--
-- Where parameters are
--        Verbose In Boolean - Verbose Output
--        RunAll  In Boolean - Run All procedures despite of Release
--        VerChk  In Number  - Check against 1st "VerChk" release numbers
--
-- Output is to the hOut package to allow output to be redirected
-- as required
--
-- Depends on:
-- hOut
--
-- Notes:
-- Must be installed in SYS schema
-- This package is intended for use in Oracle releases 9i onwards
-- This package will NOT work in 8i or earlier.
-- In all cases any output reporting "problems" should be
-- parsed by an experienced Oracle Support analyst to confirm
-- if any action is required.
--
-- CAUTION
-- The sample program in this article is provided for educational
-- purposes only and is NOT supported by Oracle Support Services.
-- It has been tested internally, however, and works as documented.
-- We do not guarantee that it will work for you, so be sure to test
-- it in your environment before relying on it.
--
--------------------------------------------------------------------------
--Create Or Replace Package hcheck Is
  Type sFuncNam Is Table Of Varchar2(32) Index By Binary_integer ;
  Type sFuncRel Is Table Of Varchar2(32) Index By Binary_integer ;
--
  sFn sFuncNam ;     /* Function Names                              */
  sFr sFuncRel ;     /* Version Control: Fixed Release per function */
--
-- Procedure Definitions
--
  Procedure SynLastDDLTim       
         (nF In Number Default 0, VerChk In Number Default 5,
            Verbose In Boolean Default FALSE) ; /*  1 */
  Procedure LobNotInObj         
         (nF In Number Default 0, VerChk In Number Default 5,
            Verbose In Boolean Default FALSE) ; /*  2 */
  Procedure MissingOIDOnObjCol 
         (nF In Number Default 0, VerChk In Number Default 5,
            Verbose In Boolean Default FALSE) ; /*  3 */
  Procedure SourceNotInObj     
         (nF In Number Default 0, VerChk In Number Default 5,
            Verbose In Boolean Default FALSE) ; /*  4 */
  Procedure IndIndparMismatch   
         (nF In Number Default 0, VerChk In Number Default 5,
            Verbose In Boolean Default FALSE) ; /*  5 */
  Procedure InvCorrAudit       
         (nF In Number Default 0, VerChk In Number Default 5,
            Verbose In Boolean Default FALSE) ; /*  6 */
  Procedure OversizedFiles     
         (nF In Number Default 0, VerChk In Number Default 5,
            Verbose In Boolean Default FALSE) ; /*  7 */
  Procedure TinyFiles           
         (nF In Number Default 0, VerChk In Number Default 5,
            Verbose In Boolean Default FALSE) ; /*  8 */
  Procedure PoorDefaultStorage 
         (nF In Number Default 0, VerChk In Number Default 5,
            Verbose In Boolean Default FALSE) ; /*  9 */
  Procedure PoorStorage         
         (nF In Number Default 0, VerChk In Number Default 5,
            Verbose In Boolean Default FALSE) ; /* 10 */
  Procedure MissTabSubPart     
         (nF In Number Default 0, VerChk In Number Default 5,
            Verbose In Boolean Default FALSE) ; /* 11 */
  Procedure PartSubPartMismatch 
         (nF In Number Default 0, VerChk In Number Default 5,
            Verbose In Boolean Default FALSE) ; /* 12 */
  Procedure TabPartCountMismatch
         (nF In Number Default 0, VerChk In Number Default 5,
            Verbose In Boolean Default FALSE) ; /* 13 */
  Procedure OrphanedTabComPart
         (nF In Number Default 0, VerChk In Number Default 5,
            Verbose In Boolean Default FALSE) ; /* 14 */
  Procedure ZeroTabSubPart
         (nF In Number Default 0, VerChk In Number Default 5,
            Verbose In Boolean Default FALSE) ; /* 15 */
  Procedure MissingSum$
         (nF In Number Default 0, VerChk In Number Default 5,
            Verbose In Boolean Default FALSE) ; /* 16 */
  Procedure MissingDir$
         (nF In Number Default 0, VerChk In Number Default 5,
            Verbose In Boolean Default FALSE) ; /* 17 */
  Procedure DuplicateDataobj
         (nF In Number Default 0, VerChk In Number Default 5,
            Verbose In Boolean Default FALSE) ; /* 18 */
  Procedure ObjSynMissing
         (nF In Number Default 0, VerChk In Number Default 5,
            Verbose In Boolean Default FALSE) ; /* 19 */
  Procedure ObjSeqMissing
         (nF In Number Default 0, VerChk In Number Default 5,
            Verbose In Boolean Default FALSE) ; /* 20 */
  Procedure OrphanedUndo
         (nF In Number Default 0, VerChk In Number Default 5,
            Verbose In Boolean Default FALSE) ; /* 22 */
  Procedure OrphanedIndex
         (nF In Number Default 0, VerChk In Number Default 5,
            Verbose In Boolean Default FALSE) ; /* 21 */
  Procedure OrphanedIndexPartition
         (nF In Number Default 0, VerChk In Number Default 5,
            Verbose In Boolean Default FALSE) ; /* 23 */
  Procedure OrphanedIndexSubPartition
         (nF In Number Default 0, VerChk In Number Default 5,
            Verbose In Boolean Default FALSE) ; /* 24 */
  Procedure OrphanedTable
         (nF In Number Default 0, VerChk In Number Default 5,
            Verbose In Boolean Default FALSE) ; /* 25 */
  Procedure OrphanedTablePartition
         (nF In Number Default 0, VerChk In Number Default 5,
            Verbose In Boolean Default FALSE) ; /* 26 */
  Procedure OrphanedTableSubPartition
         (nF In Number Default 0, VerChk In Number Default 5,
            Verbose In Boolean Default FALSE) ; /* 27 */
  Procedure MissingPartCol
         (nF In Number Default 0, VerChk In Number Default 5,
            Verbose In Boolean Default FALSE) ; /* 28 */
  Procedure OrphanedSeg$
         (nF In Number Default 0, VerChk In Number Default 5,
            Verbose In Boolean Default FALSE) ; /* 29 */
  Procedure OrphanedIndPartObj#
         (nF In Number Default 0, VerChk In Number Default 5,
            Verbose In Boolean Default FALSE) ; /* 30 */
  Procedure DuplicateBlockUse
         (nF In Number Default 0, VerChk In Number Default 5,
            Verbose In Boolean Default FALSE) ; /* 31 */
  Procedure HighObjectIds
         (nF In Number Default 0, VerChk In Number Default 5,
            Verbose In Boolean Default FALSE) ; /* 32 */
  Procedure PQsequence
         (nF In Number Default 0, VerChk In Number Default 5,
            Verbose In Boolean Default FALSE) ; /* 33 */
  Procedure TruncatedCluster
         (nF In Number Default 0, VerChk In Number Default 5,
            Verbose In Boolean Default FALSE) ; /* 34 */
  Procedure FetUet
         (nF In Number Default 0, VerChk In Number Default 5,
            Verbose In Boolean Default FALSE) ; /* 35 */
  Procedure Uet0Check
         (nF In Number Default 0, VerChk In Number Default 5,
            Verbose In Boolean Default FALSE) ; /* 36 */
  Procedure ExtentlessSeg
         (nF In Number Default 0, VerChk In Number Default 5,
            Verbose In Boolean Default FALSE) ; /* 37 */
  Procedure SeglessUET
         (nF In Number Default 0, VerChk In Number Default 5,
            Verbose In Boolean Default FALSE) ; /* 38 */
  Procedure BadInd$
         (nF In Number Default 0, VerChk In Number Default 5,
            Verbose In Boolean Default FALSE) ; /* 39 */
  Procedure BadTab$
         (nF In Number Default 0, VerChk In Number Default 5,
            Verbose In Boolean Default FALSE) ; /* 40 */
  Procedure BadIcolDepCnt
         (nF In Number Default 0, VerChk In Number Default 5,
            Verbose In Boolean Default FALSE) ; /* 41 */
  Procedure WarnIcolDep
         (nF In Number Default 0, VerChk In Number Default 5,
            Verbose In Boolean Default FALSE) ; /* 42 */
  Procedure OnlineRebuild$
         (nF In Number Default 0, VerChk In Number Default 5,
            Verbose In Boolean Default FALSE) ; /* 43 */
  Procedure DropForceType
         (nF In Number Default 0, VerChk In Number Default 5,
            Verbose In Boolean Default FALSE) ; /* 44 */
  Procedure TrgAfterUpgrade
         (nF In Number Default 0, VerChk In Number Default 5,
            Verbose In Boolean Default FALSE) ; /* 45 */
  Procedure FailedInitJVMRun
         (nF In Number Default 0, VerChk In Number Default 5,
            Verbose In Boolean Default FALSE) ; /* 46 */
  Procedure TypeReusedAfterDrop
         (nF In Number Default 0, VerChk In Number Default 5,
            Verbose In Boolean Default FALSE) ; /* 47 */
  Procedure Idgen1$TTS
         (nF In Number Default 0, VerChk In Number Default 5,
            Verbose In Boolean Default FALSE) ; /* 48 */
  Procedure DroppedFuncIdx
         (nF In Number Default 0, VerChk In Number Default 5,
            Verbose In Boolean Default FALSE) ; /* 49 */
  Procedure BadOwner
         (nF In Number Default 0, VerChk In Number Default 5,
            Verbose In Boolean Default FALSE) ; /* 50 */
  Procedure UpgCheckc0801070
         (nF In Number Default 0, VerChk In Number Default 5,
            Verbose In Boolean Default FALSE) ; /* 51 */
  Procedure BadPublicObjects
         (nF In Number Default 0, VerChk In Number Default 5,
            Verbose In Boolean Default FALSE) ; /* 52 */
  Procedure BadSegFreelist
         (nF In Number Default 0, VerChk In Number Default 5,
            Verbose In Boolean Default FALSE) ; /* 53 */
  Procedure BadCol#
         (nF In Number Default 0, VerChk In Number Default 5,
            Verbose In Boolean Default FALSE) ; /* 54 */
  Procedure BadDepends
         (nF In Number Default 0, VerChk In Number Default 5,
            Verbose In Boolean Default FALSE) ; /* 55 */
  Procedure CheckDual
         (nF In Number Default 0, VerChk In Number Default 5,
            Verbose In Boolean Default FALSE) ; /* 56 */
  Procedure ObjectNames
         (nF In Number Default 0, VerChk In Number Default 5,
            Verbose In Boolean Default FALSE) ; /* 57 */
  Procedure BadCboHiLo
         (nF In Number Default 0, VerChk In Number Default 5,
            Verbose In Boolean Default FALSE) ; /* 58 */
  Procedure ChkIotTs
         (nF In Number Default 0, VerChk In Number Default 5,
            Verbose In Boolean Default FALSE) ; /* 59 */
  Procedure NoSegmentIndex
         (nF In Number Default 0, VerChk In Number Default 5,
            Verbose In Boolean Default FALSE) ; /* 60 */
  Procedure BadNextObject
         (nF In Number Default 0, VerChk In Number Default 5,
            Verbose In Boolean Default FALSE) ; /* 61 */
  Procedure OrphanIndopt
         (nF In Number Default 0, VerChk In Number Default 5,
            Verbose In Boolean Default FALSE) ; /* 62 */
  Procedure UpgFlgBitTmp
         (nF In Number Default 0, VerChk In Number Default 5,
            Verbose In Boolean Default FALSE) ; /* 63 */
  Procedure RenCharView
         (nF In Number Default 0, VerChk In Number Default 5,
            Verbose In Boolean Default FALSE) ; /* 64 */
  Procedure Upg9iTab$
         (nF In Number Default 0, VerChk In Number Default 5,
            Verbose In Boolean Default FALSE) ; /* 65 */
  Procedure Upg9iTsInd
         (nF In Number Default 0, VerChk In Number Default 5,
            Verbose In Boolean Default FALSE) ; /* 66 */
  Procedure Upg10gInd$
         (nF In Number Default 0, VerChk In Number Default 5,
            Verbose In Boolean Default FALSE) ; /* 67 */
  Procedure DroppedROTS
         (nF In Number Default 0, VerChk In Number Default 5,
            Verbose In Boolean Default FALSE) ; /* 68 */
  Procedure ChrLenSmtcs
         (nF In Number Default 0, VerChk In Number Default 5,
            Verbose In Boolean Default FALSE) ; /* 69 */
  Procedure FilBlkZero
         (nF In Number Default 0, VerChk In Number Default 5,
            Verbose In Boolean Default FALSE) ; /* 70 */
  Procedure DbmsSchemaCopy
         (nF In Number Default 0, VerChk In Number Default 5,
            Verbose In Boolean Default FALSE) ; /* 71 */
--
  bRun  Boolean      ;
  nFunc Number := 71 ; /* should be equal-to, not one-greater-than, the */
                     /* highest expected number of procedures to be run */
--
-- Function  CatV2nCatV ( s In Varchar2, n in Number default 5 ) Return Number ;
-- Procedure ChecknCatVnFR ( nCatV In Number, nFR In Number ) ;
--
-- Main
--
  Procedure Full (Verbose In Boolean Default FALSE,
                  RunAll  In Boolean Default FALSE,
                  VerChk  In Number  Default 5) ;
End hcheck;
/Create Or Replace Package Body hcheck Is
    Ver        Varchar2(10) := "9i+/hc3.50";
    Warn     Number     :=0            ;
    Fatal      Number     :=0            ;
    CatV     Varchar2(10)                ;
    nCatV      Number     :=0            ;
    Verbose    Boolean                   ;
    nFR        Number     :=0            ; /* Fixed Release */
--
  Function InitsFr Return sFuncRel Is
    AllReleases Varchar2(32) := "99.99.99.99.99" ;
  Begin
--
-- Highest Relevant Release For Functions
-- If check against all releases, specify "99.99.99.99.99"
--
    sFr (0) := AllReleases            ; /*  0 */
    sFr (1) := "10.1.0.2.0"         ; /*  1 */
    sFr (2) := "10.0.0.2.0"         ; /*  2 */
    sFr (3) := AllReleases            ; /*  3 */
    sFr (4) := "10.2.0.1.0"         ; /*  4 */
    sFr (5) := "11.2.0.1.0"         ; /*  5 */
    sFr (6) := "11.2.0.1.0"         ; /*  6 */
    sFr (7) := AllReleases            ; /*  7 */
    sFr (8) :=  "9.0.1.0.0"         ; /*  8 */
    sFr (9) := AllReleases            ; /*  9 */
    sFr(10) := AllReleases            ; /* 10 */
    sFr(11) :=  "9.0.1.0.0"         ; /* 11 */
    sFr(12) := "11.2.0.1.0"         ; /* 12 */
    sFr(13) := AllReleases            ; /* 13 */
    sFr(14) :=  "9.0.1.0.0"         ; /* 13 */
    sFr(15) :=  "9.2.0.1.0"         ; /* 15 */
    sFr(16) := AllReleases            ; /* 16 */
    sFr(17) := AllReleases            ; /* 17 */
    sFr(18) := AllReleases            ; /* 18 */
    sFr(19) := AllReleases            ; /* 19 */
    sFr(20) := AllReleases            ; /* 20 */
    sFr(21) := AllReleases            ; /* 21 */
    sFr(22) := AllReleases            ; /* 22 */
    sFr(23) := AllReleases            ; /* 23 */
    sFr(24) := AllReleases            ; /* 24 */
    sFr(25) := AllReleases            ; /* 25 */
    sFr(26) := AllReleases            ; /* 26 */
    sFr(27) := AllReleases            ; /* 27 */
    sFr(28) := AllReleases            ; /* 28 */
    sFr(29) := AllReleases            ; /* 29 */
    sFr(30) := "11.1.0.6.0"         ; /* 30 */
    sFr(31) := AllReleases            ; /* 31 */
    sFr(32) :=  "8.1.6.0.0"         ; /* 32 */
    sFr(33) :=  "8.0.6.0.0"         ; /* 33 */
    sFr(34) :=  "8.1.7.0.0"         ; /* 34 */
    sFr(35) := AllReleases            ; /* 35 */
    sFr(36) := AllReleases            ; /* 36 */
    sFr(37) := AllReleases            ; /* 37 */
    sFr(38) := AllReleases            ; /* 38 */
    sFr(39) := AllReleases            ; /* 39 */
    sFr(40) := AllReleases            ; /* 40 */
    sFr(41) := "11.1.0.7.0"         ; /* 41 */
    sFr(42) := "11.1.0.7.0"         ; /* 42 */
    sFr(43) := AllReleases            ; /* 43 */
    sFr(44) := "10.1.0.2.0"         ; /* 44 */
    sFr(45) := AllReleases            ; /* 45 */
    sFr(46) := AllReleases            ; /* 46 */
    sFr(47) :=  "9.0.1.0.0"         ; /* 47 */
    sFr(48) :=  "9.0.1.0.0"         ; /* 48 */
    sFr(49) :=  "9.2.0.1.0"         ; /* 49 */
    sFr(50) :=  "9.0.1.0.0"         ; /* 50 */
    sFr(51) := AllReleases            ; /* 51 */
    sFr(52) := AllReleases            ; /* 52 */
    sFr(53) := AllReleases            ; /* 53 */
    sFr(54) := "10.1.0.2.0"         ; /* 54 */
    sFr(55) := AllReleases            ; /* 55 */
    sFr(56) := AllReleases            ; /* 56 */
    sFr(57) := AllReleases            ; /* 57 */
    sFr(58) := AllReleases            ; /* 58 */
    sFr(59) := AllReleases            ; /* 59 */
    sFr(60) := AllReleases            ; /* 60 */
    sFr(61) := AllReleases            ; /* 61 */
    sFr(62) :=  "9.2.0.8.0"         ; /* 62 */
    sFr(63) := "10.1.0.1.0"         ; /* 63 */
    sFr(64) := "10.1.0.1.0"         ; /* 64 */
    sFr(65) :=  "9.2.0.4.0"         ; /* 65 */
    sFr(66) :=  "9.2.0.5.0"         ; /* 66 */
    sFr(67) := "10.2.0.0.0"         ; /* 67 */
    sFr(68) := AllReleases            ; /* 68 */
    sFr(69) := "11.1.0.6.0"         ; /* 69 */
    sFr(70) := AllReleases            ; /* 70 */
    sFr(71) := AllReleases            ; /* 70 */
--
    Return sFr ;
  End ;
--
  Function Owner (uid Number) Return Varchar2 Is
    r          Varchar2(30) := Null        ;
  Begin
    Select name Into r
    From user$
    where  user# = uid ;    return r ;
  Exception
    When NO_DATA_FOUND Then
      Return ( "*UnknownOwnID="||uid||"*" ) ;
  End ;
--
  Function ObjName (objid Number) Return Varchar2 Is
    r          Varchar2(30) := Null        ;
    own        Number                      ;
  Begin
    Select name, owner# Into r, own
    From obj$
    Where  Obj# = objid ;
    return r ;
  Exception
    When NO_DATA_FOUND Then
      Return ( "*UnknownObjID="||objid||"*" ) ;
  End ;
--
  Function IsLastPartition( o number ) Return Boolean Is
    n Number := 0 ;
  Begin
    Select partcnt Into n From partobj$ where obj#=o ;
    If ( n>1 ) Then
      Return(FALSE) ;
    Else
      Return(TRUE) ;
    End If ;
  End;
--
  Function ObjectIsTemporary( o Number ) Return Boolean
  -- Return TRUE if object is a TEMPORARY object
  -- Return NULL if object does not exist
  -- Return FALSE if object is not temporary
  Is
    Cursor cIsTemp Is
      Select Bitand(nvl(flags,0), 2) IsTemp From obj$ Where obj#=o
    ;
    ret Boolean := FALSE ;
  begin
    For R in cIsTemp Loop -- For loop just to keep cursor closed
      If ( R.IsTemp=2 ) Then
        ret := TRUE ;
      End If;
    End Loop ;
    return ret ;
  End;
--
  Procedure DictAt( ts number, fi number, bl number ) is
 Cursor cDictAt is
   select typ, ts#,file#,block#,count("x") CNT
      from (
    select "UNDO$" typ, u.ts#, u.file#, u.block# from undo$ u
       where decode(u.status$,1,null,u.status$) is not null
    UNION ALL
    select "TAB$"        typ, a.ts#,a.file#,a.block# from tab$        a
    UNION ALL
    select "CLU$"        typ, b.ts#,b.file#,b.block# from clu$        b
    UNION ALL
    select "TABPART$"    typ, c.ts#,c.file#,c.block# from tabpart$    c
    UNION ALL
    select "TABSUBPART$" typ, d.ts#,d.file#,d.block# from tabsubpart$ d
    UNION ALL
    select "IND$"        typ, e.ts#,e.file#,e.block# from ind$        e
    UNION ALL
    select "INDPART$"    typ, f.ts#,f.file#,f.block# from indpart$    f
    UNION ALL
    select "INDSUBPART$" typ, g.ts#,g.file#,g.block# from indsubpart$ g
    UNION ALL
    select "LOB$"        typ, h.ts#,h.file#,h.block# from lob$        h
    UNION ALL
    select "LOBFRAG$"    typ, i.ts#,i.file#,i.block# from lobfrag$    i
--  UNION ALL
--  select "RECYCLEBIN$" typ, j.ts#,j.file#,j.block# from recyclebin$ j
     )
     where ts#= TS and file# = FI and block#= BL
     group by typ, ts#,file#,block#
      ;
  Begin
 For R in cDictAt
 Loop
   hout.put_line("^  "||R.typ||" has "||R.cnt||" rows");
 End Loop;
  End;
--
  function IndexIsNosegment( o number ) return boolean is
 Cursor cX is
    select bitand(flags,4096) noseg from ind$ where obj#=o;
 ret boolean:=null;
  begin
 For C in cX
 loop
   if C.noseg=4096 then
    ret:=true;
   else
    ret:=false;
   end if;
 end loop;
 return ret;  /* true/false or NULL if not found */
  end;
--
 Procedure CheckIndPart( o number ) is
    Cursor Cchk is
    select  i.obj#, i.dataobj#, i.ts#, i.file#, i.block#
          from indpart$ i
   where i.bo#=o
     and (i.file#!=0 OR i.block#!=0);
 begin
    For R in Cchk Loop
   hout.put_line(" ^- PROBLEM: Child INDPART$ with FILE/BLK (bug 4683380)");
   hout.put_line(" ^- ( OBJ="||R.obj#|| " DOBJ="||r.dataobj#||
        " TS="||r.TS#||
        " RFILE/BLOCK="||r.file#||" "||r.block#||")" );
   Fatal:=Fatal+1;
    end loop;
 end;
--
  Procedure ChecknCatVnFR ( nCatV In   Number,
                            nFR In   Number,
                            bRun  In Out Boolean) Is
    str1 Varchar2(10) := To_Char(nCatV) ;
    str2 Varchar2(10) := To_Char(nFR) ;
  Begin
    Case
      When ( nCatV =          0 ) Then
        str1 := "*Any Rel*" ;
    Else
      Null ;
    End Case ;
    Case
      When ( nFR = 9999999999 ) Then
        str2 := "*All Rel*" ;
      Else
        Null ;
    End Case ;
    If ( nCatV > nFR ) Then
      hout.put_line(Rpad(nCatv,10," ")||" > "||Lpad(nFR,11," ")||" : n/a");
      bRun := FALSE ;
      return ;
    Else
      hout.put_line(Rpad(str1,10," ")||" <="||Lpad(str2,11," ")||" : Ok") ;
      bRun := TRUE ;
    End If ;
  End ;
--
  Procedure strtok (tok In Out Varchar2, s In Out Varchar2, ct In Varchar2) Is
    i         Pls_integer      ;
    p         Pls_integer      ;
    len       Pls_integer      ;
    token_start Pls_integer      ;
    intoken   Boolean := FALSE ;
  Begin
    -- dbms_output.put_line ( "strtok string: "||s ) ;
    If ( s Is Not NULL ) Then
      len := length( s ) ;
      i := 1 ;
      While ( i <= len ) Loop
        p := instr( ct, substr(s,i,1) );
        If ( ( i = len ) Or ( p > 0 ) ) Then
          If ( intoken ) Then
            If ( p > 0 ) Then
              tok := substr( s, token_start, i - token_start ) ;
              s := substr( s, i+1 ) ;
            Else
              tok := substr( s, token_start, i - token_start + 1 ) ;
              s := "" ;
            End If ;
            Exit When TRUE ;
          End If ;
        Elsif ( Not intoken ) Then
            intoken := true ;
            token_start := i ;
        End If;
        tok := s ;
        i := i + 1 ;
      End Loop;
    End if;
  End;
--
  Function CatV2nCatV ( s In Varchar2, n in Number default 5 ) Return Number As
    type tok is table of Number index by binary_integer ;
    tk tok ;
    scp varchar2(16) ;
    i number := 1 ;
    scv Varchar2(16) := Null ;
  Begin
    scp := s ;
    for i in 1..n loop
      tk(i) := Null ;
      strtok( tk(i), scp, "." );
      scv := scv || Lpad(tk(i),2,"0") ;
    end loop ;
    return To_Number(scv) ;
  end;
--
  Procedure SynLastDDLTim
         (nF      In Number  Default 0,
            VerChk  In Number  Default 5,
            Verbose In Boolean Default FALSE)
  Is
    Cursor sCur1 Is
      Select Distinct o.obj#, o.owner#, o.name
      From obj$ o, idl_ub1$ i
      Where  type#  = 5
      And    ctime != mtime
      And    i.obj# = o.obj#    /* Has IDL information */
      ;
    nFr  Number ;
    ps1  Varchar2(10) := "HCKW-0001" ;
    ps1a Varchar2(65) :=
       "Synonym""s LAST_DDL_TIME != CREATED" ;
    bug1 Varchar2(80) :=
       "Ref    : Bug:2371453" ;
    aff1 Varchar2(80) := "Affects: Vers >=8.1.7.2 and BELOW 10.1 - "||
       "Specifically: 8.1.7.4 9.0.1.3 9.2.0.1" ;
    fix1 Varchar2(80) :=
       "Fixed  : 8.1.7.5 9.0.1.4 9.2.0.2 10.1.0.2" ;
    tag1 Varchar2(80) :=
       "CORR/DIC HCHECK "||ps1 ;
    not1 Varchar2(80) :=
       "Note: 2371453.8 - CREATE OR REPLACE SYNONYM can lead to inconsistent";
    not2 Varchar2(80) :=
       "                  dictionary (old IDL data)" ;
    CursorRun Boolean := FALSE ; V Boolean := Verbose ;
    Begin
      If ( nF = 0) Then
        sFr := InitsFr ;
      End If ;
      If ( nF = 0) Then
        sFr := InitsFr ;
      End If ;
      nFr := hcheck.CatV2nCatV ( sFr(nF), VerChk );
      ChecknCatVnFR (nCatV, nFR, bRun) ;
      If ( bRun = FALSE ) Then return ; End If ;
      For c1 in sCur1 Loop
        If (ps1 Is Not Null) Then
            CursorRun := TRUE ;
            hout.put_line (chr(10)||ps1||": "||ps1a) ;
            ps1:=null;
        End If;
       If ( V ) Then
          if (bug1 Is Not Null) Then hout.put_line(bug1); bug1:=null; End If;
          if (aff1 Is Not Null) Then hout.put_line(aff1); aff1:=null; End If;
          if (fix1 Is Not Null) Then hout.put_line(fix1); fix1:=null; End If;
          if (tag1 Is Not Null) Then hout.put_line(tag1); tag1:=null; End If;
          if (not1 Is Not Null) Then hout.put_line(not1); not1:=null; End If;
          if (not2 Is Not Null) Then hout.put_line(not2); not2:=null; End If;
          hout.put(chr(10)); V := FALSE ;
        End If ;
        hout.put_line(" OBJ#="||c1.OBJ#||" Name="||Owner(c1.owner#)||"."||
                      c1.name);
        Warn := Warn + 1 ;
      End Loop ;
      If ( CursorRun ) Then hout.put(chr(10)) ; End If ;
    End ;
--
  Procedure LobNotInObj
         (nF      In Number  Default 0,
            VerChk  In Number  Default 5,
            Verbose In Boolean Default FALSE)
  Is
    nFr  Number ;
    Cursor sCur1 Is
      Select l.obj#, l.lobj#
      From lob$ l, obj$ o
      Where  l.lobj# = o.obj#(+)
      And    o.obj# is null
      ;
    ps1  Varchar2(10) := "HCKE-0001" ;
    ps1a Varchar2(65) := "LOB$.LOBJ# not found in OBJ$" ;
    bug1 Varchar2(80) :=
       "Ref    : Bug:2405258" ;
    aff1 Varchar2(80) :=
       "Affects: Vers >=8 and BELOW 10.1 - Specifically: 9.2.0.1" ;
    fix1 Varchar2(80) :=
       "Fixed  : 9.2.0.2 10.1.0.2" ;
    tag1 Varchar2(80) :=
       "CORR/DIC HCHECK "||ps1 ;
    not1 Varchar2(80) :=
       "Note: 2405258.8 - Dictionary corruption / OERI(15265) from MOVE LOB" ;
    not2 Varchar2(80) :=
       "                  to existing segment name" ;
    CursorRun Boolean := FALSE ; V Boolean := Verbose ;
    Begin
      If ( nF = 0) Then
        sFr := InitsFr ;
      End If ;
      If ( nF = 0) Then
        sFr := InitsFr ;
      End If ;
      nFr := hcheck.CatV2nCatV ( sFr(nF), VerChk );
      ChecknCatVnFR (nCatV, nFR, bRun) ;
      If ( bRun = FALSE ) Then return ; End If ;
      For c1 In sCur1 Loop
        If (ps1 Is Not Null) Then
            CursorRun := TRUE ;
            hout.put_line (chr(10)||ps1||": "||ps1a) ;
            ps1:=null;
        End If;
       If ( V ) Then
          if (bug1 Is Not Null) Then hout.put_line(bug1); bug1:=null; End If;
          if (aff1 Is Not Null) Then hout.put_line(aff1); aff1:=null; End If;
          if (fix1 Is Not Null) Then hout.put_line(fix1); fix1:=null; End If;
          if (tag1 Is Not Null) Then hout.put_line(tag1); tag1:=null; End If;
          if (not1 Is Not Null) Then hout.put_line(not1); not1:=null; End If;
          if (not2 Is Not Null) Then hout.put_line(not2); not2:=null; End If;
          hout.put(chr(10)); V := FALSE ;
        End If ;
        hout.put_line(" LOB$.LOBJ# has no OBJ$ entry for LOBJ#="||c1.lobj#||
                      " (OBJ#="||c1.obj#||")");
        Fatal := Fatal + 1 ;
      End Loop ;
      If ( CursorRun ) Then hout.put(chr(10)) ; End If ;
    End ;
--
  Procedure MissingOIDOnObjCol
         (nF      In Number  Default 0,
            VerChk  In Number  Default 5,
            Verbose In Boolean Default FALSE)
  Is
    nFr  Number ;
    Cursor sCur1 Is
      Select o.obj# , o.type#, o.owner#, o.name, c.col#, c.intcol#,
             c.name cname, t.property
      From obj$ o, col$ c, coltype$ ct, oid$ oi, tab$ t
      Where  o.obj#   = ct.obj#
      And    ct.obj#    = c.obj#
      And    ct.col#    = c.col#
      And    ct.intcol# = c.intcol#
      And    oi.oid$(+) = ct.toid
      And    o.obj#   = t.obj#(+)
      And    oi.oid$ is null
      ;
    ps1  Varchar2(10) := "HCKE-0002" ;
    ps1a Varchar2(65) := "Object type column with missing OID$" ;
    bug1 Varchar2(80) :=
       "Ref    : Bug:2728624" ;
    aff1 Varchar2(80) :=
       "Affects: Closed as not a Bug (92)" ;
    fix1 Varchar2(80) :=
       "Fixed  : See Note.229583.1 for patching steps" ;
    tag1 Varchar2(80) :=
       "CORR/DIC HCHECK "||ps1 ;
    not1 Varchar2(80) :=
       "Note.229583.1 - Bug:2728624 - Confirmation and Patching Notes" ;
    CursorRun Boolean := FALSE ; V Boolean := Verbose ;
    Begin
      If ( nF = 0) Then
        sFr := InitsFr ;
      End If ;
      If ( nF = 0) Then
        sFr := InitsFr ;
      End If ;
      nFr := hcheck.CatV2nCatV ( sFr(nF), VerChk );
      ChecknCatVnFR (nCatV, nFR, bRun) ;
      If ( bRun = FALSE ) Then return ; End If ;
      For c1 In sCur1 Loop
        If (ps1 Is Not Null) Then
            CursorRun := TRUE ;
            hout.put_line (chr(10)||ps1||": "||ps1a) ;
            ps1:=null;
        End If;
       If ( V ) Then
          if (bug1 Is Not Null) Then hout.put_line(bug1); bug1:=null; End If;
          if (aff1 Is Not Null) Then hout.put_line(aff1); aff1:=null; End If;
          if (fix1 Is Not Null) Then hout.put_line(fix1); fix1:=null; End If;
          if (tag1 Is Not Null) Then hout.put_line(tag1); tag1:=null; End If;
          if (not1 Is Not Null) Then hout.put_line(not1); not1:=null; End If;
          hout.put(chr(10)); V := FALSE ;
        End If ;
        hout.put_line(" OBJ#="||c1.obj#||" Name="||Owner(c1.owner#)||"."
                      ||c1.name||" IntCol#="||c1.intcol#||"="||c1.cname
                      ||" TabProp="||c1.property);
        Fatal := Fatal + 1 ;
      End Loop ;
      If ( CursorRun ) Then hout.put(chr(10)) ; End If ;
    End ;
--
  Procedure SourceNotInObj
         (nF      In Number  Default 0,
            VerChk  In Number  Default 5,
            Verbose In Boolean Default FALSE)
  Is
    nFr  Number ;
    Cursor sCur1 Is
      Select Count("x") cnt, Count(Distinct s.obj#) nobj
      From source$ s, obj$ o
      Where  s.obj# = o.obj#(+)
      And    o.obj# is null
      Having Count("x") > 0
      ;
    ps1  Varchar2(10) := "HCKE-0003" ;
    ps1a Varchar2(65) := "SOURCE$ for OBJ# not in OBJ$" ;
    bug1 Varchar2(80) :=
       "Ref    : Bug:3532977" ;
    aff1 Varchar2(80) :=
       "Affects: Vers BELOW 10.2 Specifically: 9.2.0.4 10.1.0.4" ;
    fix1 Varchar2(80) :=
       "Fixed  : 9.2.0.8 10.1.0.5 10.2.0.1" ;
    tag1 Varchar2(80) :=
       "CORR/DIC HCHECK "||ps1 ;
    not1 Varchar2(80) := Null ;
    CursorRun Boolean := FALSE ; V Boolean := Verbose ;
    Begin
      If ( nF = 0) Then
        sFr := InitsFr ;
      End If ;
      nFr := hcheck.CatV2nCatV ( sFr(nF), VerChk );
      ChecknCatVnFR (nCatV, nFR, bRun) ;
      If ( bRun = FALSE ) Then return ; End If ;
      For c1 In sCur1 Loop
        If (ps1 Is Not Null) Then
            CursorRun := TRUE ;
            hout.put_line (chr(10)||ps1||": "||ps1a) ;
            ps1:=null;
        End If;
       If ( V ) Then
          if (bug1 Is Not Null) Then hout.put_line(bug1); bug1:=null; End If;
          if (aff1 Is Not Null) Then hout.put_line(aff1); aff1:=null; End If;
          if (fix1 Is Not Null) Then hout.put_line(fix1); fix1:=null; End If;
          if (tag1 Is Not Null) Then hout.put_line(tag1); tag1:=null; End If;
          if (not1 Is Not Null) Then hout.put_line(not1); not1:=null; End If;
          hout.put(chr(10)); V := FALSE ;
        End If ;
        hout.put_line("SOURCE$ has "||c1.cnt||
           " rows for "||c1.nobj||" OBJ# values not in OBJ$" ) ;
        Fatal := Fatal + 1 ;
      End Loop ;
      If ( CursorRun ) Then hout.put(chr(10)) ; End If ;
    End ;
--
  Procedure IndIndparMismatch
         (nF      In Number  Default 0,
            VerChk  In Number  Default 5,
            Verbose In Boolean Default FALSE)
  Is
    nFr  Number ;
    Cursor sCur1 Is
      Select io.obj# io, io.name ionam, ipo.obj# ipo, ipo.name iponam
      From obj$ io, indpart$ ip, obj$ ipo
      Where  ipo.type#       = 20  /* IND PART */
      And    ip.obj#      &nbs