改變表已新增約束 外來鍵

2021-03-31 08:56:31 字數 867 閱讀 1789

alter table [dbo].[employee] with nocheck add

constraint [df__employee__job_id__1b0907ce] default (1) for [job_id],

constraint [df__employee__job_lv__1cf15040] default (10) for [job_lvl],

constraint [df__employee__pub_id__1de57479] default ('9952') for [pub_id],

constraint [df__employee__hire_d__1fcdbceb] default (getdate()) for [hire_date],

constraint [pk_emp_id] primary key  nonclustered

([emp_id]

)  on [primary] ,

constraint [ck_emp_id] check ([emp_id] like '[a-z][a-z][a-z][1-9][0-9][0-9][0-9][0-9][fm]' or [emp_id] like '[a-z]-[a-z][1-9][0-9][0-9][0-9][0-9][fm]')

goalter table [dbo].[employee] add

foreign key

([job_id]

) references [dbo].[jobs] (

[job_id]

),foreign key

([pub_id]

) references [dbo].[publishers] (

[pub_id])go

Oracle表中新增外來鍵約束

新增主鍵約束 alter table ga airline add constraint pk airline id primary key airline id 有三種形式的外來鍵約束 1 普通外來鍵約束 如果存在子表引用父表主鍵,則無法刪除父表記錄 2 級聯外來鍵約束 可刪除存在引用的父表記錄,...

Mysql 為表新增外來鍵約束

sql語句格式 新增外來鍵約束 alter table 從表 add constraint 外來鍵 形如 fk 從表 主表 foreign key 從表外來鍵欄位 references 主表 主鍵欄位 如果mysql報錯 error code 1215.cannot add foreign key ...

oracle新增外來鍵約束

alter table gjjy.jy dic crop drop constraint fk zmlb alter table gjjy.jy dic crop drop constraint fk zwlb alter table gjjy.jy dic crop add constraint ...

SQL新增外來鍵約束

1,sql語句建立表的同時新增外來鍵約束 create table tb userandrole 使用者角色表 id int primary key identity 1,1 userid int not null,使用者id roleid int not null,角色id foreign key...

Mysql新增外來鍵約束

最近學習遇到一條新增外來鍵約束的語句,記錄下來.alter table selection add constraint fk reference 1 foreign key course references course id on delete restrict on update restr...