关于CONSTRAINT

1.可延迟约束

SELECT   * FROM   user_constraints 查询所有约束

alter table child add constraint  fk_child foreign key (parent_name)

references parent (parent_name) deferrable ;

取消延迟:

set constraint fk_child immediate ;

2.检查约束

   alter table temp add constraint ck_temp_age check ((age>0) and (age <= 125))

3.自引用约束

   alter table professors add constraint fk_professors_prof_name foreign key (dept_head)

   references professors (prof_name);--当然prof_name需为primary key;

4.禁用/激活约束(禁用/激活约束会引起删除和重建索引的操作)
alter table employees disable/enable unique email
alter table employees disable/enable constraint emp_ename_pk
alter tabel employees modify constraint emp_pk disable/enable
alter tabel employees modify constraint emp_ename_phone_uk disable/enable

ALTER TABLE employees DROP CONSTRAINT emp_deptno_fk;删除约束

5.级联删除

   alter table students add constraint fk_students_state foreign key (state) references state_lookup(state) on delete cascade ;

6.多列属性约束

   alter table students add constraint uk_students_lic unique (state,license) ;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值