TA的每日心情 | 开心 2021-12-13 21:45 |
---|
签到天数: 15 天 [LV.4]偶尔看看III
|
/*创建唯一约束*/
alter table dept add constraints dept_id_uk unique(DNAME);
/*添加主键约束*/
alter table dept add constraint dept_no_pk primary key (deptno);
/*添加外键约束*/
alter table employees add constraint emp_dept_fk foreign key(department_id)
references departments(department_id);
/*添加自定义约束*/
alter table employees add constraint emp_salary_min check (salary > 0);
/*删除约束*/
alter table employees drop constraint emp_manager_fk;
alter table departments drop primary key cascade;
/*使用约束生效/失效*/
alter table employees disable constraint emp_id_pk cascade;
alter table employees enable constraint emp_id_pk
/*查询系统中存在哪些约束 --查不出数据来*/
select constraint_name,constraint_type,search_condition
from user_constraints
where table_name='dept';;
转载请注明:java学习者论坛 http://www.javaxxz.com
|
|