1.创建一张表student
id number
name varchar2(20)
age number(5)
tel varchar2(15)
给id字段添加主键约束
给name字段添加非空约束
给age字段添加check约束(18-35)
给tel添加唯一非空约束
create table student( id number primary key, name varchar2(20) not null, age number(5) check(age between 18 and 35), tel varchar2(15) unique not null);
2.创建一张学员兴趣表hobby
id number(10)
hobby_name varchar2(20)
sid number --学生id
给sid字段添加外键约束,并且要带级联删除create table hobby( id number(10), hobby_name varchar2(20), sid number references student(id) on delete cascade);
3.删除掉student表中tel字段的唯一约束(先写出查看该表约束的sql)select constraint_name,constraint_type from all_constraints where user_table=upper('student');alter table student drop constraint unique(tel);
4.手动添加student表中tel字段的唯一约束(约束名为:my_constraint_1)alter table student add constraint my_constraint_1 unique(tel);
5.禁用约束my_constraint_1alter table student disable constraint my_constraint_1;
6.启用约束 my_constraint_1alter table student enable constraint my_constraint_1;
-