ITPub博客

首页 > 数据库 > 数据库开发技术 > 【基础知识】ORACLE数据库错误概述

【基础知识】ORACLE数据库错误概述

原创 数据库开发技术 作者:lukeunique 时间:2019-05-05 12:05:00 0 删除 编辑

Keyword:

ORA- , ERROR, ORACLE数据库错误 ,ORA-nnnn,oerr


概述


本文为数据库错误(如ORA-nnnn等)的概要和一般处理方法的介绍。


ORACLE错误的表示形式

ORACLE数据库表示的错误,通常由3个字母加上5个数字来组成,如:ORA-nnnnn,TNS-nnnnn等,其中:


  • 前3个字母代表错误发生的组件,如:ORA代表是服务器端发生的错误,TNS代表是网络方面发生的错误。

  • 后5个数字则代表错误的具体含义,如:ORA-00001代表违反唯一约束条件等。



ORACLE错误分类

ORACLE数据库错误主要可以分为内部错误和外部错误,也可细分为以下几类:

错误的一般原因和处理方法


对于ORACLE数据库错误,可以通过下面途径了解到简要的错误原因和处理方法。


1.官方在线文档


官方在线文档的错误手册中,对数据库常见的错误进行了简要的错误原因描述和处理意见,在遇到错误时可以第一时间进行查询。



参考:Home/Database/Oracle/Oracle Database/Release 12.2Error Messageshttps://docs.oracle.com/database/122/ERRMG/toc.htm



2. oerr命令

在安装了ORACLE数据库软件的机器上,可以通过在命令行中输入以下的命令查看。


oerr <错误组件> <错误号>


例:


对于ORA-00001错误,可以通过如下查询:-bash-4.1$ oerr ora 100001, 00000, "unique constraint (%s.%s) violated"// *Cause: An UPDATE or INSERT statement attempted to insert a duplicate key.// For Trusted Oracle configured in DBMS MAC mode, you may see// this message if a duplicate entry exists at a different level.// *Action: Either remove the unique restriction or do not insert the key.


3.通过安装数据库后的如下文件查看


$ORACLE_HOME/rdbms/mesg/*.msg


所有错误相关的文件:
-bash-4.1$ cd $ORACLE_HOME/rdbms/mesg-bash-4.1$ ls *.msgamduus.msg    diaus.msg  kfedus.msg  kopus.msg  ocius.msg  rmanus.msg  udius.msgasmcmdus.msg  expus.msg  kfodus.msg  kupus.msg  opwus.msg  sbtus.msg   ulus.msgdbvus.msg     gimus.msg  kfsgus.msg  lcdus.msg  oraus.msg  smgus.msgdgmus.msg     impus.msg  kgpus.msg   nidus.msg  qsmus.msg  udeus.msg


ORA-错误相关的文件为oraus.msg,在Linux环境下可以通过more/cat/tail等命令查看:

tail -20 $ORACLE_HOME/rdbms/mesg/oraus.msg
例:-bash-4.1$ tail -20 $ORACLE_HOME/rdbms/mesg/oraus.msg////////////////////////////////////////////////////////////////////////////65530, 00000, "CELLCACHE feature not supported for IOTs"// *Document: NO// *Cause: An attempt was made to enable the CELLCACHE feature for an// index-organized table.// *Action: None./65531, 00000, "maximum level reached in index segment with object id %s"// *Cause: The attempted operation resulted in the number of index levels// exceeding the maximum allowed.// *Action: Reduce the size of the relevant index, for example, by using// compression or partitioning./65535, 00000, "Oracle client cannot handle error code exceeding 65535. Actual error code and message follow:\n"// *Cause: Oracle server encountered an error whose error code exceeded 65535.// Older Oracle clients (prior to version 12) cannot handle error// codes larger than 65535.// *Action: Actual Oracle error code and error message are a part of the error// message for ORA-65535. Upgrade Oracle client to version 12 client// libraries or higher.

ORACLE错误原因的进一步调查


通过简要的错误原因和处理方法,基本可以解决80%的问题。
如果需要的话,可以通过如下方法进一步调查。


1.查看告警日志(Alert Log)中服务器是否自动输出更详细的诊断信息及TRACE文件

2.查看错误发生时间附近相关TRACE文件,看是否能够获得有效信息

3.如果数据库服务器没有自动输出诊断信息,可尝试设置错误发生时的诊断事件取得errorstack等相关诊断信息


    例如,在ORA-00001错误发生时,输出errorstack诊断信息。
--有效 alter system set events '1 trace name errorstack level 3';
--无效 alter system set events '1 trace name errorstack off';


用碎片化的时间,一点一滴地学习一套系统化的知识。


原文作者:SQL和数据库技术;如有侵权,请联系管理员删除。

请登录后发表评论 登录
全部评论

注册时间:2017-07-21

  • 博文量
    107
  • 访问量
    63571