ABORT
When an applicable constraint violation occurs,the ABORT resolution algorithm aborts the current sql statement with an sqlITE_CONSTRAIT error and backs out any changes made by the current sql statement; but changes caused by prior sql statements within the same transaction are preserved and the transaction remains active. This is the default behavior and the behavior proscribed the sql standard.FAIL
When an applicable constraint violation occurs,the FAIL resolution algorithm aborts the current sql statement with an sqlITE_CONSTRAINT error. But the FAIL resolution does not back out prior changes of the sql statement that Failed nor does it end the transaction. For example,if an UPDATE statement encountered a constraint violation on the 100th row that it attempts to update,then the first 99 row changes are preserved but changes to rows 100 and beyond never occur.
两者都保留在导致约束违规并且不结束事务的语句之前所做的更改.因此,我认为唯一的区别是FAIL解决方案不允许进行进一步的更改,而ABORT只备份冲突的语句.我做对了吗?
考虑这两个表:
CREATE TABLE IF NOT EXISTS constFAIL (num UNIQUE ON CONFLICT FAIL); CREATE TABLE IF NOT EXISTS constABORT (num UNIQUE ON CONFLICT ABORT); INSERT INTO constFAIL VALUES (1),(3),(4),(5),(6),(7),(8),(9),(10); INSERT INTO constABORT VALUES (1),(10);
该声明
UPDATE constABORT SET num=num+1 WHERE num<10
会失败并且什么都不改变.
但是这个声明
UPDATE constFAIL SET num=num+1 WHERE num<10
将更新第一行,然后失败并保持1行更新,因此新值为2,3,4,5,6,7,8,9,10