You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

13 lines
251 B

  1. CREATE TABLE t1 (
  2. f1 INT NOT NULL PRIMARY KEY,
  3. f2 INT,
  4. FOREIGN KEY (f2)
  5. REFERENCES t1(f1)
  6. ON DELETE CASCADE
  7. ) ENGINE=InnoDB;
  8. INSERT INTO t1 VALUES (1, 1), (2, 1);
  9. DELETE FROM t1 WHERE f1 = 1;
  10. SELECT COUNT(*) = 0 FROM t1;
  11. COUNT(*) = 0
  12. 1
  13. DROP TABLE t1;