我正在使用 sqlite3 版本3.8.8.3,我想知道以下问题是否会导致预期结果:
BEGIN TRANSACTION;
CREATE TABLE ta (
a integer(10) NOT NULL,
id integer NOT NULL PRIMARY KEY );
INSERT INTO "ta" VALUES(1,1);
INSERT INTO "ta" VALUES(2,2);
INSERT INTO "ta" VALUES(3,3);
CREATE TABLE tb (
a integer(10) NOT NULL,
CONSTRAINT c
UNIQUE (a) );
INSERT INTO "tb" VALUES(2);
INSERT INTO "tb" VALUES(1);
CREATE TRIGGER t AFTER UPDATE ON ta
FOR EACH ROW WHEN (old.a != new.a )
BEGIN INSERT OR REPLACE INTO tb(a) SELECT new.a; END;
COMMIT;
update or rollback ta set a=3;
- >错误:UNIQUE约束失败:tb.a