建好表之后,新增或修改,删除约束
****************************
先用此语句查看某个表的所有约束:
select TABLE_NAME,CONSTRAINT_NAME,SEARCH_CONDITION,STATUS from user_constraints WHERE TABLE_name=upper(‘&TABLE_Name‘);
0.增加not null约束
alter table student modify sname not null;
1.修改null约束
alter table student modify sname null;/*姓名可以为空*/
2.增加主键约束
alter table student
add constraint pk_student
primary key(id);
3.删除主键约束
先用此语句查看某个表的所有约束:
select TABLE_NAME,CONSTRAINT_NAME,SEARCH_CONDITION,STATUS from user_constraints WHERE TABLE_name=upper(‘&TABLE_Name‘);
这里要删除的是约束"fk_student"
alter table drop constraint fk_student;
4.增加外键约束
alter table sc
add cons