求大侠帮忙!急急急!
--添加约束(sno 为主键 sex的值只能为男和女,age的范围是16-28)
create table student (
sno char(6) primary key,
sname varchar2(10),
sex char(2),
age number(3),
dept varchar2(10)
);
alter table student
add constraint CK_age check(age between 16 and 28);
alter table student
add constraint CK_sex check(sex in('男','女'));
--课程表
create table course (
cno char(5) primary key,
cname varchar2(12),
ccredit number ---学分
);
--选课表
--(添加约束 sno cno 为联合主键 同时还是外键)
create table sc(
sno char(6),
cno char(5),
score number(3)
primary key (sno,cno));
alter table sc
add constraint FK_sno foreign key(sno) references student(sno);
sno,cno,同时还为外键不知道怎么写。求帮忙!!!!!!
------解决方案--------------------SQL> alter table sc add constraint sc_fk1 foreign key(sno) references
2 student(sno) on delete cascade;
Table altered.
SQL> alter table sc add constraint sc_fk2 foreign key(cno) references
2 course(cno) on delete cascade;
Table altered.