blob: 62ec9f85cd47a2604476c1b34b82770d267e7232 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
CREATE TABLE t0 (
f1 INT PRIMARY KEY,
f2 INT UNIQUE
) ENGINE=INNODB;
CREATE TABLE t1 (
f1 INT PRIMARY KEY,
FOREIGN KEY (f1)
REFERENCES t0(f1)
ON UPDATE CASCADE
) ENGINE=INNODB;
CREATE TABLE t2 (
f2 INT PRIMARY KEY,
FOREIGN KEY (f2)
REFERENCES t0(f2)
ON UPDATE CASCADE
) ENGINE=INNODB;
INSERT INTO t0 VALUES (0, 0);
INSERT INTO t1 VALUES (0);
INSERT INTO t2 VALUES (0);
UPDATE t0 SET f1 = 1, f2 = 2;
SELECT f1 = 1 FROM t1 WHERE f1 = 1;
f1 = 1
1
SELECT f2 = 2 FROM t2 WHERE f2 = 2;
f2 = 2
1
SELECT f1 = 1 FROM t1;
f1 = 1
1
SELECT f2 = 2 FROM t2;
f2 = 2
1
DROP TABLE t2;
DROP TABLE t1;
DROP TABLE t0;
|