--创建学生表 student
Create Table Scott.student
(
sno char(12)Primary key,
sname nchar(4)not null,
ssex nchar(1) check(ssex in ('男','女')),
sage smallint,
sdept char(2)
);
-创建课程表 course
create table scott.course
(
cno char(4) primary key,
cname nvarchar2(20) not null unique,
cpno char(4) references scott.course(cno),
ccredit smallint default 4 not null check(ccredit between 1 and 6)
);
--创建选课表 sc
create table scott.sc
(
sno char(12) references scott.student(sno),
cno char (4) references scott.course(cno),
grade smallint check(grade between 0 and 100),
primary key (sno,cno)
);
Insert into student values(‘201308010001’,’张珊珊’,’女’,’20’,’JK’);
Insert into student values(‘201308010002’,’吴军’,’男’,’21’,’JK’);
Insert into student values(‘201308010003,’孙皓然’,’男’,’19’,’JK’);
Insert into student values(‘201508080001,’李丽’,’女’,’20’,’JK’);
Insert into course values(‘0001’,’大学体育’,’NULL’,’2’);
Insert into course values(‘0002’,’高等数学’,’NULL’,’4’);
Insert into course values(‘0003’,’数据结构’,’0002’,’4’);
Insert into course values(‘0004’,’数据库技术’,’0002’,’3’);
Insert into sc values(‘201308010001’,’0001’,’96’);
Insert into sc values(‘201308010002’,’0001’,’80’);
Insert into sc values(‘201308010003’,’0002’,’65’);
Insert into sc values(‘201508080008’,’0005’,’100’);