如何知道在使用DAT文件向表中插入条目时导致约束失败的原因是什么?

问题描述 投票:1回答:1

我正在使用DAT文件向表中插入多个条目。我如何知道哪些记录导致约束失败(例如重复约束)?我正在使用informix dbaccess加载条目。

以下是我如何加载它的示例代码:

load from 'table.dat'
insert into table (
    col1,
    col2,
    col3
);

这是我得到的错误。它显示了sql代码从哪里失败但它并没有告诉我哪个特定的行失败了。

  268: Unique constraint (test.tableconstraint) violated.

  100: ISAM error:  duplicate value for a record with unique key.
Error in line 1
Near character position 0

informix dbaccess
1个回答
3
投票

你有几个选择:

  1. 使用DB-Load(dbload)代替DB-Access来加载数据。 DBLOAD Load Utility INFORMIX-SQL Version 12.10.FC6 Usage: dbload [-d dbname] [-c cfilname] [-l logfile] [-e errnum] [-n nnum] [-i inum] [-s] [-p] [-r | -k] [-X] -d database name -c command file name -l bad row(s) log file -e bad row(s) # before abort -s syntax error check only -n # of row(s) before commit -p prompt to commit or not on abort -i # of row(s) to ignore before starting -r loading without locking table -X recognize HEX escapes in character fields -k loading with exclusive lock on table(s)
  2. 使用START VIOLATIONS TABLESTOP VIOLATIONS TABLE。这将记录违反一个表中约束的数据,并在另一个表中提供诊断信息。如果需要,可以指定辅助表名称,但默认值是带有后缀_vio_dia的基表名称。

尝试两者 - 我怀疑违规表是更好的选择,但两者都有效。

© www.soinside.com 2019 - 2024. All rights reserved.