SQL之约束

来源:互联网 发布:花千骨网络视频 编辑:程序博客网 时间:2024/05/16 04:38

 

ALTER TABLE student add constraint def_ssex default  '男'  FOR  ssex


ALTER TABLE student add constraint che_sdept check (sdept in('CS','MA','IS'))            //check后面是布尔表达式


alter table student add constraint uni_sname unique(sname)


alter table sc add constraint fk_S_c foreign key(sno) references student(sno)

 

临时关闭约束:  alter table student NOCHECK constraint che_sdept

重新打开约束alter table student CHECK constraint che_sdept

删除约束:       altertable student drop constraint che_sdept

原创粉丝点击