mirror of
https://github.com/tursodatabase/libsql.git
synced 2024-12-13 12:28:30 +00:00
ad79ef48a2
* add tests * add bench
47 lines
907 B
Plaintext
47 lines
907 B
Plaintext
|
|
PRAGMA foreign_keys = 1;
|
|
|
|
CREATE TABLE s1(a PRIMARY KEY, b);
|
|
CREATE TABLE par(a, b REFERENCES s1, c UNIQUE, PRIMARY KEY(a));
|
|
|
|
CREATE TABLE c1(a, b REFERENCES par);
|
|
CREATE TABLE c2(a, b REFERENCES par);
|
|
CREATE TABLE c3(a, b REFERENCES par(c));
|
|
|
|
|
|
CREATE TABLE pX(x PRIMARY KEY);
|
|
CREATE TABLE cX(a INTEGER PRIMARY KEY, b REFERENCES pX);
|
|
|
|
|
|
CREATE TABLE p4 (id INTEGER NOT NULL PRIMARY KEY);
|
|
INSERT INTO p4 VALUES(1), (2), (3);
|
|
|
|
CREATE TABLE c4(x INTEGER REFERENCES p4(id) DEFERRABLE INITIALLY DEFERRED);
|
|
CREATE INDEX c4_x ON c4(x);
|
|
INSERT INTO c4 VALUES(1), (2), (3);
|
|
|
|
ANALYZE;
|
|
INSERT INTO p4(id) VALUES(4);
|
|
|
|
|
|
PRAGMA foreign_keys = true;
|
|
CREATE TABLE parent(
|
|
p PRIMARY KEY
|
|
);
|
|
CREATE TABLE child(
|
|
c UNIQUE REFERENCES parent(p)
|
|
);
|
|
|
|
|
|
SELECT * FROM child;
|
|
|
|
|
|
PRAGMA foreign_key_check;
|
|
|
|
|
|
SELECT * FROM child;
|
|
|
|
|
|
PRAGMA foreign_key_check;
|
|
|