Oracle 11g 记录DML错误数据

Posted 天空之城

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Oracle 11g 记录DML错误数据相关的知识,希望对你有一定的参考价值。

[From] https://oracle-base.com/articles/10g/dml-error-logging-10gr2

需要记录下大量DML操作中出错的具体record,看到有两种方案,一种是使用批量DML操作bulk collect并带上save exceptions子句,然后做处理。稍微繁琐,不想使用。于是用另一种方案,就是在DML语句后面跟上LOG ERRORS。

 

LOG ERRORS [INTO [schema.]table] [(‘simple_expression‘)] [REJECT LIMIT integer|UNLIMITED]



The optional INTO clause allows you to specify the name of the error logging table. If you omit this clause, the the first 25 characters of the base table name are used along with the "ERR$_" prefix.

The simple_expression is used to specify a tag that makes the errors easier to identify. This might be a string or any function whose result is converted to a string.

The REJECT LIMIT is used to specify the maximum number of errors before the statement fails. The default value is 0 and the maximum values is the keyword UNLIMITED. For parallel DML operations, the reject limit is applied to each parallel server.

其中,这个错误记录表需要先创建,可以使用包 exec DBMS_ERRLOG.CREATE_ERROR_LOG(‘target_table‘); 来创建。第一个参数就是需要被记录DML操作的目标表。如果不附加参数,则默认会创建表名为ERR&_target_table的表。之后就可以使用LOG ERRORS了,使用默认表名时,log errors 后面可以不需要into。

以上是关于Oracle 11g 记录DML错误数据的主要内容,如果未能解决你的问题,请参考以下文章

『ORACLE』 对永久表空间进行DML操作(11g)

从Oracle存储过程Oracle 11g发送邮件

Flyway 3.1 数据库迁移多个模式 - Oracle 11g

记录在Windows Server 2008 R2 中安装Oracle 11g r2

在 oracle11g系统中 约束的类型都有哪些

oracle11g数据库安装采坑记录