mirror of
https://github.com/MariaDB/server.git
synced 2025-01-19 13:32:33 +01:00
20 lines
1 KiB
Text
20 lines
1 KiB
Text
DROP TABLE IF EXISTS t1,t2;
|
|
CREATE TABLE t1 (id INT NOT NULL, PRIMARY KEY (id)) ENGINE=INNODB;
|
|
CREATE TABLE t2 (id INT PRIMARY KEY, t1_id INT, INDEX par_ind (t1_id),
|
|
FOREIGN KEY (t1_id) REFERENCES t1(id) ON DELETE CASCADE,
|
|
FOREIGN KEY (t1_id) REFERENCES t1(id) ON UPDATE CASCADE) ENGINE=INNODB;
|
|
select * from information_schema.TABLE_CONSTRAINTS where
|
|
TABLE_SCHEMA= "test";
|
|
CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE
|
|
NULL test PRIMARY test t1 PRIMARY KEY
|
|
NULL test PRIMARY test t2 PRIMARY KEY
|
|
NULL test t2_ibfk_1 test t2 FOREIGN KEY
|
|
NULL test t2_ibfk_2 test t2 FOREIGN KEY
|
|
select * from information_schema.KEY_COLUMN_USAGE where
|
|
TABLE_SCHEMA= "test";
|
|
CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION POSITION_IN_UNIQUE_CONSTRAINT
|
|
NULL test PRIMARY NULL test t1 id 1 NULL
|
|
NULL test PRIMARY NULL test t2 id 1 NULL
|
|
NULL test t2_ibfk_1 NULL test t2 t1_id 1 1
|
|
NULL test t2_ibfk_2 NULL test t2 t1_id 1 1
|
|
drop table t2, t1;
|