2
組合唯一我想要實現在MySQL以下限制:MySQL在FK的
create table TypeMapping(
...
constraint unique(server_id,type_id),
constraint foreign key(server_id) references Server(id),
constraint foreign key(type_id) references Type(id)
);
這將引發 'ERROR 1062(23000):重複錄入'關鍵 'SERVER_ID'' 3-4的時候我發出一個可以打破約束的插入/更新。這種約束甚至可能嗎?如果是這樣如何?謝謝。
是的,我沒有想到這實際上是預期的行爲。 :S – m2o 2010-04-12 16:18:54