Server

MySQL 建立Foreign Key ( InnoDB ) 時要注意的一件事

今天在測試資料庫刪除資料時,發現了一件事 在有被其他資料表 Reference 成 Foreign Key 的情況下刪除資料時資料庫會發出: Cannot delete or update a parent row: a foreign key constraint fails 後來才發現在建立資料庫時,如果不會自己的 Foreign Key 設定動作的話,資料庫預設是不會做連動的更改( NO ACTION )。 ————————————–  CREATE TABLE parent(    id INT NOT NULL,    PRIMARY KEY (id) ) TYPE = INNODB; CREATE TABLE child(    id INT,    parent_id INT,    INDEX par_
ipstor