oracle数据字典一致性检查

一.数据字典一致性检查

MOS 文档说明:Identify Data Dictionary Inconsistency [ID 456468.1]

1.1 数据字典损坏

数据字典损坏通常有如下情况:

1. Data Dictionary Inconsistency, missingrows in tables:

         - Tab$/Ind$ with no entries in OBJ$
          - Undo$/Tab$/Ind$ withno entries in SEG$
          - Seg$ with no entriesin TAB$/IND$/OBJ$
2. Missing data dictionary objects
3. Corrupted data dictionary objects (table, index, or table-indexinconsistency)
4. Invalid entries in data dictionary tables.

数据字典损坏对系统的影响是可能某些用户和对象无法进行删除,当遇到这种情况时,就可以检查一下数据字典的一致性。

1.2 识别数据字典的不一致性

In order todetect data dictionary inconsistency we need to run hcheck.full procedure,see Note136697.1.
       --为了检查数据字典的不一致性,Oracle 提供了hcheck.fuu 过程。其具体的使用方法如下:

a. Connect asSYS schema in sqlplus
       b. Create package hOut as described in Note101468.1
       c. Create package hcheck in SYS schema asdescribed in Note136697.1 attachment.
       d. set serveroutput on
       e. execute hcheck.full

The script willreport various dictionary related issues that may or may not be aproblem. Any problems reported should be reviewed by an experiencedsupport analyst as some reported "problems" may be normal andexpected.

--该脚本会报告数据字典相关的各种问题

Example of HCHECK.FULL output:

--个HCHECK.FULL输出示例

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 thehcheck.full output you will have to identify the objects that show a ddinconsistency, and verify the reported inconsistency.

--根据这个输出结果,我们可以验证这个不一致性:

Selectname,type# from obj$ where obj#=<OBJ>; /* 1=INDEX, 2=TABLE, 3=CLUSTER,21=LOB, 25=IOT

Selectobject_name,owner,object_type from dba_objects whereobject_id=<OBJ>;

Some of theproblems, mainly the one marked as  'May be OK. Needs manual check ' couldbe a false alarm.

Check the typeof the object.

Lob Index ontemporary table or IOT do not have a segment, than the problem message is afalse alarm.

二.Hcheck 脚本

MOS 文档:

Script to Install the "hOut"Helper Package ("hout.sql") [ID 101468.1]

"hcheck.sql" script to check forknown problems in Oracle8i, Oracle9i, Oracle10g and Oracle 11g [ID 136697.1]

 

三.示例

3.1 用SYS 用户创建Hout包

脚本参考[ID101468.1]

3.2 在SYS用户下创建hcheck包

脚本参考:[ID 136697.1]

3.3 执行hcheck.full

SQL>@E:\Software\OracleSoftware\Hcheck_Full_Scripts\hout.sql

Package created.

No errors.

Package body created.

--这里注意,MOS上对hcheck脚本提供了2个版本:hcheck2.sql 和 hcheck3.sql。

--执行hcheck2.sql

SQL> @E:\Software\OracleSoftware\Hcheck_Full_Scripts\hcheck2.sql

Package created.

No errors.

Package body created.

No errors.

SQL>

SQL> exec hcheck.full

HCheck Version 8i-11/2.00  --version 2 对应的是8i

Problem: SEG$ bad LISTS/GROUPS (==1) - See Tar:2470806.1

May be Ok for LOBSEGMENT/SECUREFILE inrelease 11gR1+

Bad SEG$ lists/groups : TS#=1 RFILE#=2BLK#=22177 TYPE#=8 Lists=2 Groups=1

Bad SEG$ lists/groups : TS#=1 RFILE#=2BLK#=22233 TYPE#=8 Lists=2 Groups=1

Bad SEG$ lists/groups : TS#=1 RFILE#=2BLK#=22937 TYPE#=8 Lists=2 Groups=1

Bad SEG$ lists/groups : TS#=1 RFILE#=2BLK#=22977 TYPE#=8 Lists=2 Groups=1

Bad SEG$ lists/groups : TS#=1 RFILE#=2BLK#=23017 TYPE#=8 Lists=2 Groups=1

Bad SEG$ lists/groups : TS#=1 RFILE#=2BLK#=24505 TYPE#=8 Lists=2 Groups=1

Warning: OBJECT name clashes with SCHEMA name - Bug:2894111 etc..

Schema=DAVE Object=DAVE.DAVE (TABLE)

Schema=DVD Object=DVD.DVD (TABLE)

Found 6 potential problems and 2 warnings

Contact Oracle Support with the output

to check if the above needs attention ornot

PL/SQL procedure successfully completed.

--执行hcheck3.sql

SQL> @E:\Software\OracleSoftware\Hcheck_Full_Scripts\hcheck3.sql

Package created.

Package body created.

SQL> spool D:\hcheck.txt

SQL> exec hcheck.full

H.Check Version 9i+/hc3.35  --version 3对应的是9i

---------------------------------------

Catalog Version 11.2.0.1.0 (1102000100)

---------------------------------------

                                   Catalog       Fixed

Procedure Name                     Version    Vs Release      Run

------------------------------ ...---------- -- ----------   ---

.- SynLastDDLTim               ... 1102000100 >  1001000200 : n/a

.- LobNotInObj                 ... 1102000100 >  1000000200 : n/a

.- MissingOIDOnObjCol          ... 1102000100 <=  *All Rel* : Ok

.- SourceNotInObj              ... 1102000100 >  1002000100 : n/a

.- IndIndparMismatch           ... 1102000100 <= 1102000100 : Ok

.- InvCorrAudit                ... 1102000100 <= 1102000100: Ok

.- OversizedFiles              ... 1102000100 <=  *All Rel* : Ok

.- TinyFiles                   ... 1102000100 >   900010000 : n/a

.- PoorDefaultStorage          ... 1102000100 <=  *All Rel* : Ok

.- PoorStorage                 ... 1102000100 <=  *All Rel* : Ok

.- MissTabSubPart              ... 1102000100 >   900010000 : n/a

.- PartSubPartMismatch         ... 1102000100 <= 1102000100 : Ok

.- TabPartCountMismatch        ... 1102000100 <=  *All Rel* : Ok

.- OrphanedTabComPart          ... 1102000100 >   900010000 : n/a

.- ZeroTabSubPart              ... 1102000100 >   902000100 : n/a

.- MissingSum$                 ... 1102000100 <=  *All Rel* : Ok

.- MissingDir$                 ... 1102000100 <=  *All Rel* : Ok

.- DuplicateDataobj            ... 1102000100 <=  *All Rel* : Ok

.- ObjSynMissing               ... 1102000100 <=  *All Rel* : Ok

.- ObjSeqMissing               ... 1102000100 <=  *All Rel* : Ok

.- OrphanedUndo                ... 1102000100 <=  *All Rel* : Ok

.- OrphanedIndex               ... 1102000100 <=  *All Rel* : Ok

.- OrphanedIndexPartition      ... 1102000100 <=  *All Rel* : Ok

.- OrphanedIndexSubPartition   ... 1102000100 <=  *All Rel* : Ok

.- OrphanedTable               ... 1102000100 <=  *All Rel* : Ok

.- OrphanedTablePartition      ... 1102000100 <=  *All Rel* : Ok

.- OrphanedTableSubPartition   ... 1102000100 <=  *All Rel* : Ok

.- MissingPartCol              ... 1102000100 <=  *All Rel* : Ok

.- OrphanedSeg$                ... 1102000100 <=  *All Rel* : Ok

.- OrphanedIndPartObj#         ... 1102000100 >  1101000600 : n/a

.- DuplicateBlockUse           ... 1102000100 <=  *All Rel* : Ok

.- HighObjectIds               ... 1102000100 >   801060000 : n/a

.- PQsequence                  ... 1102000100 >   800060000 : n/a

.- TruncatedCluster            ... 1102000100 >   801070000 : n/a

.- FetUet                      ... 1102000100 <=  *All Rel* : Ok

.- Uet0Check                   ... 1102000100 <=  *All Rel* : Ok

.- ExtentlessSeg               ... 1102000100 <=  *All Rel* : Ok

.- SeglessUET                  ... 1102000100 <=  *All Rel* : Ok

.- BadInd$                     ... 1102000100 <=  *All Rel* : Ok

.- BadTab$                     ... 1102000100 <=  *All Rel* : Ok

.- BadIcolDepCnt               ... 1102000100 >  1101000700 : n/a

.- WarnIcolDep                 ... 1102000100 >  1101000700 : n/a

.- OnlineRebuild$              ... 1102000100 <=  *All Rel* : Ok

.- DropForceType               ... 1102000100 >  1001000200 : n/a

.- TrgAfterUpgrade             ... 1102000100 <=  *All Rel* : Ok

.- FailedInitJVMRun            ... 1102000100 <=  *All Rel* : Ok

.- TypeReusedAfterDrop         ... 1102000100 >   900010000 : n/a

.- Idgen1$TTS                  ... 1102000100 >   900010000 : n/a

.- DroppedFuncIdx              ... 1102000100 >   902000100 : n/a

.- BadOwner                    ... 1102000100 >   900010000 : n/a

.- UpgCheckc0801070            ... 1102000100 <=  *All Rel* : Ok

.- BadPublicObjects            ... 1102000100 <=  *All Rel* : Ok

.- BadSegFreelist              ... 1102000100 <=  *All Rel* : Ok

.- BadCol#                     ... 1102000100 >  1001000200 : n/a

.- BadDepends                  ... 1102000100 <=  *All Rel* : Ok

.- CheckDual                   ... 1102000100 <=  *All Rel* : Ok

.- ObjectNames                 ... 1102000100 <=  *All Rel* : Ok

HCKW-0018: OBJECT name clashes with SCHEMAname

Schema=DAVE Object=DAVE.DAVE (TABLE)

Schema=DVD Object=DVD.DVD (TABLE)

.- BadCboHiLo                  ... 1102000100 <=  *All Rel* : Ok

.- ChkIotTs                    ... 1102000100 <=  *All Rel* : Ok

.- NoSegmentIndex              ... 1102000100 <=  *All Rel* : Ok

.- BadNextObject               ... 1102000100 <=  *All Rel* : Ok

.- OrphanIndopt                ... 1102000100 >   902000800 : n/a

.- UpgFlgBitTmp                ... 1102000100 >  1001000100 : n/a

.- RenCharView                 ... 1102000100 >  1001000100 : n/a

.- Upg9iTab$                   ... 1102000100 >   902000400 : n/a

.- Upg9iTsInd                  ... 1102000100 >   902000500 : n/a

.- Upg10gInd$                  ... 1102000100 >  1002000000 : n/a

.- DroppedROTS                 ... 1102000100 <=  *All Rel* : Ok

.- ChrLenSmtcs                 ... 1102000100 >  1101000600 : n/a

.- FilBlkZero                  ... 1102000100 <=  *All Rel* : Ok

Found 0 potential problem(s) and 2warning(s)

Contact Oracle Support with the output

to check if the above needs attention ornot

PL/SQL procedure successfully completed.

SQL> spool off

通过以上的执行结果,hcheck 的2个脚本显示的不一样。查看这2个脚本的说明部分:

REM hcheck8i.sql      Version 2.00       Tue Mar 1 11:13:40 CET 2011

REM

REM Purpose:

REM     Toprovide a single package which looks for common data dictionary

REM     problems.

REM    Notethat this version has not been checked with locally managed

REM    tablespacesand may give spurious output if these are in use.

REM    Thisscript is for use mainly under the guidance of Oracle Support.

--这里注意的是对locallymanaged tablespace 不检测。

关于表空间类型这块,可以参考:

Oracle 自动段空间管理(ASSM:autosegment space management)

http://blog.youkuaiyun.com/tianlesoftware/article/details/4958989

REM Notes:

REM    Mustbe installed in SYS schema

REM     Thispackage is intended for use in Oracle 8.1 through 11.1

REM     This package will NOT work in 8.0 or earlier.

REM    In all cases any output reporting "problems" should be

REM     passed by an experienced Oracle Support analyst to confirm

REM     if any action is required.

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.


--------------------------------------------------------------------------

-- hcheck.sql          Version 3.35           Thu Dec 22 09:44:47 CET 2011

--

-- 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.

-- 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.

从这上面来看,2个脚本说明也一样,从版本上来看,还是推荐使用hcheck3.sql 这个脚本。

[编辑本段]Turbo C2.0    介绍      Turbo C2.0不仅是一个快捷、高效的编译程序,同时还有一个易学、易用的集成开发环境。使用Turbo C2.0无需独立地编辑、编译和连接程序,就能建立并运行C语言程序。因为这些功能都组合在Turbo 2.0的集成开发环境内,并且可以通过一个简单的主屏幕使用这些功能。    基本配置要求   Turbo C 2.0可运行于IBM-PC系列微机,包括XT,AT及IBM 兼容机。此时要求DOS2.0或更高版本支持,并至少需要448K的RAM,可在任何彩、单色80列监视器上运行。支持数学协处理器芯片,也可进行浮点仿真,这将加快程序的执行。 [编辑本段]Turbo C 2.0的主要文件的简单介绍   INSTALL.EXE 安装程序文件   TC.EXE 集成编译   TCINST.EXE 集成开发环境的配置设置程序   TCHELP.TCH 帮助文件   THELP.COM 读取TCHELP.TCH的驻留程序README 关于Turbo C的信息文件   TCCONFIG.EXE 配置文件转换程序MAKE.EXE   项目管理工具TCC.EXE   命令行编译TLINK.EXE   Turbo C系列连接器TLIB.EXE   Turbo C系列库管理工具C0?.OBJ 不   同模式启动代码C?.LIB   不同模式运行库GRAPHICS.LIB   图形库EMU.LIB   8087仿真库FP87.LIB 8087库   *.H Turbo C头文件   *.BGI 不同显示器图形驱动程序   *.C Turbo C例行程序(源文件)   其中:上面的?分别为:T Tiny(微型模式)S Small(小模式)C Compact(紧凑模式)M Medium(中型模式)L Large(大模式)H Huge(巨大模式)    Turbo C++ 3.0   “Turbo C++ 3.0”软件是Borland公司在1992年推出的强大的——C语言程序设计与C++面向对象程序设计 的集成开发工具。它只需要修改一个设置选项,就能够在同一个IDE集成开发环境下设计和编译以标准 C 和 C++ 语法设计的程序文件。 [编辑本段]C 语言   C语言起始于1968年发表的CPL语言,它的许多重要思想都来自于Martin Richards在1969年研制的BCPL语言,以及以BCPL语言为基础的与Ken Thompson在1970年研制的B语言。Ken Thompson用B语言写了第一个UNIX操作系统。M.M.Ritchie1972年在B语言的基础上研制了C语言,并用C语言写成了第一个在PDP-11计算机上研制的UNIX操作系统。1977年出现了独立于极其的C语言编译文本《看移植C语言编译程序》,从而大大简化了把C语言编译程序移植到新环境中所做的工作,这本身也就使UNIX的日益广泛使用,C语言也迅速得到推广。   1983年美国国家标准化协会(ANSI)根据C语言问世以来的各种版本,对C语言的发展和扩充制定了新的标准,成为ANSI C。1987年ANSI又公布了新标准————87ANSI C。   目前在微型计算机上使用的有Microsoft C、Quick C、Turbo C等多种版本。这些不同的C语言版本,基本部分是相同的,但是在有关规定上有略有差异。   C 语言发展如此迅速, 而且成为最受欢迎的语言之一, 主要因为它具有强大的功能。许多著名的系统软件, 如DBASE Ⅲ PLUS、DBASE Ⅳ 都是由C 语言编写的。用C 语言加上一些汇编语言子程序, 就更能显示C 语言的优势了,象PC- DOS ,WORDSTAR等就是用这种方法编写的。归纳起来C 语言具有下列特点:   1. C是中级语言   它把高级语言的基本结构和语句与低级语言的实用性结合起来。C 语言可以象汇编语言一样对位、字节和地址进行操作, 而这三者是计算机最基本的工作单元。   2. C是结构式语言   结构式语言的显著特点是代码及数据的分隔化, 即程序的各个部分除了必要的信息交流外彼此独立。这种结构化方式可使程序层次清晰, 便于使用、维护以及调试。C 语言是以函数形式提供给用户的, 这些函数可方便的调用, 并具有多种循环、条件语句控制程序流向, 从而使程序完全结构化。   3. C语言功能齐全   C 语言具有各种各样的数据类型, 并引入了指针概念, 可使程序效率更高。另外C 语言也具有强大的图形功能, 支持多种显示器和驱动器。而且计算功能、逻辑判断功能也比较强大, 可以实现决策目的。   4. C语言适用范围大   C 语言还有一个突出的优点就是适合于多种操作系统, 如DOS、UNIX,也适用于多种机型。   C语言的优点很多,但是也存在一些缺点,如运算优先级太多,运算能力方面不像其它高级语言那样强,语法定义不严格等。但是这些都不能阻止C语言成为一门广受欢迎的计算机编程语言
Turbo C2.0 介绍   Turbo C2.0不仅是一个快捷、高效的编译程序,同时还有一个易学、易用的集成开发环境。使用Turbo C2.0无需独立地编辑、编译和连接程序,就能建立并运行C语言程序。因为这些功能都组合在Turbo 2.0的集成开发环境内,并且可以通过一个简单的主屏幕使用这些功能。 基本配置要求   Turbo C 2.0可运行于IBM-PC系列微机,包括XT,AT及IBM 兼容机。此时要求DOS2.0或更高版本支持,并至少需要448K的RAM,可在任何彩、单色80列监视器上运行。支持数学协处理器芯片,也可进行浮点仿真,这将加快程序的执行。 主要文件的简单介绍   INSTALL.EXE 安装程序文件   TC.EXE 集成编译   TCINST.EXE 集成开发环境的配置设置程序   TCHELP.TCH 帮助文件   THELP.COM 读取TCHELP.TCH的驻留程序README 关于Turbo C的信息文件   TCCONFIG.EXE 配置文件转换程序MAKE.EXE   项目管理工具TCC.EXE   命令行编译TLINK.EXE   Turbo C系列连接器TLIB.EXE   Turbo C系列库管理工具C0?.OBJ 不   同模式启动代码C?.LIB   不同模式运行库GRAPHICS.LIB   图形库EMU.LIB   8087仿真库FP87.LIB 8087库   *.H Turbo C头文件   *.BGI 不同显示器图形驱动程序   *.C Turbo C例行程序(源文件)   其中:上面的?分别为:T Tiny(微型模式)S Small(小模式)C Compact(紧凑模式)M Medium(中型模式)L Large(大模式)H Huge(巨大模式)
### 回答1: 在 TURBO C 2.0 中,您可以使用 biosdisk() 函数来格式化软盘。 下面是一段代码示例: ``` #include <stdio.h> #include <dos.h> int main() { // 定义扇区的大小 unsigned int sector_size[3] = {512, 512, 1024}; // 定义填充字节 unsigned char fill_char[3] = {0xF6, 0xF6, 0x48}; // 格式化磁道 700 的前三个扇区 for (int i = 0; i < 3; i++) { int result = biosdisk(2, 0, 70, 0, i + 1, 1, sector_size[i], fill_char[i]); if (result != 0) { printf("格式化扇区 %d 失败,返回码: %d\n", i + 1, result); } } return 0; } ``` 请注意,在使用 biosdisk() 函数之前,需要包含 dos.h 头文件。 希望这能帮到您! ### 回答2使用TURBO C 2.0语言,可以通过以下代码格式化软盘的70磁道0面,并分别格式化3个扇区,大小分别为512字节、512字节和1024字节。其中,前两个扇区使用F6填充,第三个扇区使用48填充。 ```c #include<stdlib.h> #include<stdio.h> #include<dos.h> void formatFloppyDisk(){ union REGS regs; regs.h.ah = 0x0;// To format a floppy disk, we set AH=0 regs.h.dl = 0;// Drive number (0=A, 1=B, etc.) regs.x.cx = 0;// Track number to format regs.h.dh = 0;// Head number regs.h.al = 0;// Sector size (0=default, 1=512 bytes, 2=1024 bytes, 3=2048 bytes etc.) int FILL_BYTE = 0;// The byte value to fill the sectors with during formatting int NUM_SECTORS = 3;// Number of sectors to format // To format 70th track 0th head regs.x.ax = 0x1301; // 0x13 = Reset disk system, 01H = Reset only specified drive int86(0x13, &regs, &regs); // BIOS interrupt to reset disk system for (int i=0; i<NUM_SECTORS; i++){ regs.x.ax = 0x3101; // 0x31 = Write Format, 01H = Format only current track regs.x.bx = 0x0001; // 0x00 = Drive A:, 01H = Head 1, 0 = Generate ID Field depending on the disk in the drive 1 = Keep the ID Field all zeros regs.x.cx = 0x0170; // Track number=70(0-79 range) regs.h.dh = 0x00; // Head number=0 or 1 regs.h.al = 0x02; // Control byte=always zero regs.x.dx = i+1; // Sector number starting from 1 regs.x.si = 0x0000; // segment and offset of read/write buffer regs.x.di = 0x0000; // segment and offset of result if(i == 2){ FILL_BYTE = 0x48; // Fill the third sector with 48 regs.x.ax = 0x3102; // 0x31 = Write Format, 02H = Format sequential tracks immediately following the one being formatted }else{ FILL_BYTE = 0xF6; // Fill the first two sectors with F6 } regs.h.ah = FILL_BYTE; // Fill the sector with specified byte int86(0x13, &regs, &regs); // BIOS interrupt to format the specified sector } } int main(){ formatFloppyDisk(); return 0; } ``` 上述代码使用了INT 0x13,即BIOS中断服务例程,来执行软盘格式化操作。通过设置寄存器的不同参数,可以指定要格式化的磁道、面、扇区大小和填充字节。在这个例子中,我们格式化了软盘70磁道0面的3个扇区,前两个扇区使用F6填充,第三个扇区使用48填充。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值