SELECT * from stu st,course co,score sc
where st.sid = sc.sid and sc.cid = co.cid
如果我們要給 sid 做一個約束,即兩張表中的 sid 要一一對應,所以我們要添加外鍵
score 關聯 stu:
此時,更改score 中 sid 的值,因為此處的sid 必須與 stu 中的sid對應,stu 中沒有 sid= 1008,所以這個時候更改score中的sid = 1008 ,保存的時候會提示報錯