《数据库原理》
实验报告
学号: 姓名:
实验一:SQL定义功能、数据插入
1.建立教学数据库的三个基本表:
S(Sno,Sname,Ssex,Sage,Sdept) 学生(学号,姓名,性别,年龄,系) SC(Sno,Cno,Grade) 选课(学号,课程号,成绩)
C(Cno,Cname,Cpno,Ccredit) 课程(课程号,课程名,先行课,学分) __________________________________________________________________ create table S040930504
(Sno char(9) PRIMARY KEY, Sname char(40), Ssex char(2),
Sage SMALLINT, Sdept char(20) );
create table SC040930504 (Sno char(9),
Cno char(4),Grade SMALLINT );
create table C040930504 (Cno char(4), Cname char(40), Cpno char(4),
Ccredit SMALLINT, );
insert into S040930504
values('200215121','李勇','男',20,'CS'); insert into S040930504
values('200215122','刘晨','女',19,'CS'); insert into S040930504
values('20204','王敏','女',18,'MA'); insert into S040930504
values('30203','张立','男',19,'IS');
insert into SC040930504 values('200215121',1,92); insert into SC040930504 values('200215121',2,85); insert into SC040930504 values('200215121',3,88); insert into SC040930504 values('200215122',2,90); insert into SC040930504 values('200215122',3,80); insert into C040930504 values(1,'数据库','5',4); insert into C040930504
values(1,'数学', ' ',2); insert into C040930504 values(1,'信息系统','1',4); insert into C040930504 values(1,'操作系统','6',3); insert into C040930504 values(1,'数据结构','7',4); insert into C040930504 values(1,'数据处理',' ',2); insert into C040930504
values(1,'PASCAL语言','6',4);
SQL> select * from S040930504
SNO SNAME SSEX SAGE SDEPT --------- ---------------------------------------- -- ----------
200215121 李勇 男 20 CS
200215122 刘晨 女 19 CS
200215123 王敏 女 18 MA
200215125 张立 男 19 IS
SQL> select * from SC040930504 SNO CNO GRADE --------- ---- ----------
200215121 1 92 200215121 2 85 200215121 3 88 200215122 2 90 200215122 3 80
SQL> select * from C040930504
CNO CNAME CPNO CCREDIT ---- ---------------------------------------- ---- ----------
1 数据库 5 4 1 数学 2 1 信息系统 1 4 1 操作系统 6 3 1 数据结构 7 4