1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
| create table student ( sno character(10) primary key not null, sname character(10) not null, ssex character(5), sage integer, sdept character(10) );
create table course ( cno character(10) primary key not null, cname character(20) not null, cpno character(10), ccredit integer, foreign key (cpno) references course(cno) );
create table sc ( sno character(10), cno character(10), grade integer, primary key (sno, cno), foreign key (sno) references student(sno), foreign key (cno) references course(cno) );
insert into student(sno, sname, ssex, sage, sdept) values ('201215121', '李勇', '男', 20, 'CS'), ('201215122', '刘晨', '女', 19, 'CS'), ('201215123', '王敏', '女', 18, 'MA'), ('201215125', '张立', '男', 19, 'IS');
insert into course(cno, cname, cpno, ccredit) values ('1', '数据库', '5', 4), ('2', '数学', null, 2), ('3', '信息系统', '1', 4), ('4', '操作系统', '6', 3), ('5', '数据结构', '7', 4), ('6', '数据处理', null, 2), ('7', 'PASCAL语言', '6', 4);
insert into sc(sno, cno, grade) values ('201215121', '1', 92), ('201215121', '2', 85), ('201215121', '3', 88), ('201215122', '2', 90), ('201215122', '3', 80);
|