使用外部表时最新 BADFILE 的位置和文件名

Location and filename of most recent BADFILE when using external tables

有没有办法确定 location/filename 最新的 BADFILE?

当我使用 BADFILE 'mytable_%a_%p.bad' 从内部 table select 时,如何找出具体的值被 %a 和 %p 替换了?

还是我坚持使用 mytable.bad 可以可靠地查询并希望不会出现竞争条件?

如文档所述

%p is replaced by the process ID of the current process. For example, if the process ID of the access driver is 12345, then exttab_%p.log becomes exttab_12345.log.

%a is replaced by the agent number of the current process. The agent number is the unique number assigned to each parallel process accessing the external table. This number is padded to the left with zeros to fill three characters. For example, if the third parallel agent is creating a file and bad_data_%a.bad was specified as the file name, then the agent would create a file named bad_data_003.bad.

If %p or %a is not used to create unique file names for output files and an external table is being accessed in parallel, then output files may be corrupted or agents may be unable to write to the files.

话虽如此,您首先必须记住坏文件的用途。

The BADFILE clause names the file to which records are written when they cannot be loaded because of errors. For example, a record would be written to the bad file if a field in the data file could not be converted to the data type of a column in the external table. The purpose of the bad file is to have one file where all rejected data can be examined and fixed so that it can be loaded. If you do not intend to fix the data, then you can use the NOBADFILE option to prevent creation of a bad file, even if there are bad records.

所以想法(对于 SQL Loader 或具有访问驱动程序的外部表 oracle_loader )是有一个文件来存储那些记录,坏记录,而不是跟踪任何关于它们的信息。

通常,您有外部 table 与您在 daily/weekly/monthly 基础上接收的文本文件相关联。根据您自己的 table 规范,您将那些不能 read/loaded 的记录存储在坏文件中。

然后使用 LOGFILE 查找发生了什么。这些文件是在创建外部table的数据库目录中生成的,每次需要生成一个坏文件时你都会有一个。