1
我有兩個表爲什麼當我刪除主表中的行狀MySQL的ON DELETE CASCADE不行
+筆記(使用弓OS IM所以我的數據庫服務器類型爲瑪麗亞DB)
DELETE FROM buildings
WHERE
building_no = 2;
(InnoDB類型)
關係錶行不要刪除?
CREATE TABLE buildings (
building_no INT PRIMARY KEY AUTO_INCREMENT,
building_name VARCHAR(255) NOT NULL,
address VARCHAR(255) NOT NULL
);
CREATE TABLE rooms (
room_no INT PRIMARY KEY AUTO_INCREMENT,
room_name VARCHAR(255) NOT NULL,
building_no INT NOT NULL,
FOREIGN KEY (building_no)
REFERENCES buildings (building_no)
ON DELETE CASCADE
);
是兩個表輸入InnoDB? – fancyPants
是的,都是InnoDB – moh
一切都很好..!併爲我工作。 –