成人AV在线无码|婷婷五月激情色,|伊人加勒比二三四区|国产一区激情都市|亚洲AV无码电影|日av韩av无码|天堂在线亚洲Av|无码一区二区影院|成人无码毛片AV|超碰在线看中文字幕

sql數(shù)據(jù)庫外鍵怎么寫 如何設(shè)置數(shù)據(jù)庫中的外鍵?

如何設(shè)置數(shù)據(jù)庫中的外鍵?如果有外鍵,應(yīng)該先添加主表數(shù)據(jù),然后再添加輔助表數(shù)據(jù)。例如:有以下兩個表class table:CLassID nameclass 1class 2student table:

如何設(shè)置數(shù)據(jù)庫中的外鍵?

如果有外鍵,應(yīng)該先添加主表數(shù)據(jù),然后再添加輔助表數(shù)據(jù)。

例如:有以下兩個表

class table:

CLassID name

class 1

class 2

student table:

Sid name CLassID

one three 1

two Li Si 1

three Wang Wu 2

其中student表中的CLassID是class表CLassID的外鍵。

現(xiàn)在需要將sid=4、name=Zhao Liu和classsid=3的一段數(shù)據(jù)添加到student表中,因此只能先將一段新數(shù)據(jù)添加到class表中。

Insert into class table values(3,“three class”)

然后添加到student table中:

Insert into student table values(4,“Zhao Liu”,3)

mysql怎么設(shè)置外鍵?

外鍵設(shè)計(jì)的初衷是保證數(shù)據(jù)庫端操作中邏輯相關(guān)表數(shù)據(jù)的一致性和完整性。

優(yōu)點(diǎn):

外鍵引用操作列表: