SQL創(chuàng)建表外鍵語句 在SQL中如何創(chuàng)建外鍵約束?
在SQL中如何創(chuàng)建外鍵約束?添加外鍵,alter table B語法:alter table name add constraint foreign key constraint name forei
在SQL中如何創(chuàng)建外鍵約束?
添加外鍵,alter table B語法:alter table name add constraint foreign key constraint name foreign key(列名)references reference foreign key table(列名)例如:add constraint CC--表B中要約束的字段(ID)foreign key(ID)--表a后面的(ID)可以省略引用a(ID)數(shù)據(jù)查詢語言及其語句稱為“數(shù)據(jù)檢索語句”,用于從表中獲取數(shù)據(jù),并確定如何在應(yīng)用程序中給出數(shù)據(jù)。保留字select是DQL(也是所有SQL)中最常用的動詞。DQL中常用的其他保留字有where、order by、group by和having。這些DQL保留字通常與其他類型的SQL語句一起使用。
sql中怎樣創(chuàng)建外鍵約束?
兩種方法,命令和圖形。在控制臺左側(cè)的小窗格中,找到要設(shè)置的表的名稱,單擊鼠標右鍵,創(chuàng)建一個新的外鍵,然后根據(jù)需要進行設(shè)置。(創(chuàng)建新圖表-->添加表,然后拖動鼠標直接連接字段以創(chuàng)建外鍵約束。)在命令模式SQL CE表中創(chuàng)建外鍵約束的語法是:create table detecttable(userid integer,starttime datetime not null,Endtime datetime not null,massname nvarchar(10),foreignkey(userid)引用Usertable(userid)),其中userid是Usertable中的主鍵。