0
我創建MySQL中的兩個表,子表沒有被刪除
- 客戶
房子表houseID是在我的客戶表的外鍵。
Create customer table( id int not null primary key auto_increment, name varchar not null, houseId int not null, telephoneNo, int not null, CONSTRAINT FOREIGN KEY (houseId) REFERENCES house(id) ON DELETE CASCADE); CREATE house table(id int not null primary key auto_increment, houseNo int not null, address varchar not null);
然而,當我刪除用戶與特定houseId,在內部表中的行沒有被刪除,雖然我在客戶表放在刪除級聯。任何想法爲什麼?
那麼我是否需要將customerID作爲外鍵放在內部表中? – Sne
啊,它現在正在工作!謝謝! – Sne
歡迎來到堆棧溢出。請記住將問題標記爲已回答:) – Moak