最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 正文

数据库实验和参

来源:动视网 责编:小OO 时间:2025-09-24 12:08:37
文档

数据库实验和参

数据库实验和参上机实验三1.在“学生管理数据库”中用查询分析器创建p82页的课程数据表(表名为kcb),并输入数据内容。2.用查询分析器在student表中增加一个字段:“电话号码”,字符型,并设置默认值为“1111111”。3.用查询分析器删除kcb表的主键4.用企业管理器或查询分析器修改course表,设置约束:学时>=学分*16。5.用查询分析器修改学生管理数据库中的students_dat文件增容方式为一次增加3MB.6.将“学生管理数据库”更名为“学生管理”。7.将“学生管理”
推荐度:
导读数据库实验和参上机实验三1.在“学生管理数据库”中用查询分析器创建p82页的课程数据表(表名为kcb),并输入数据内容。2.用查询分析器在student表中增加一个字段:“电话号码”,字符型,并设置默认值为“1111111”。3.用查询分析器删除kcb表的主键4.用企业管理器或查询分析器修改course表,设置约束:学时>=学分*16。5.用查询分析器修改学生管理数据库中的students_dat文件增容方式为一次增加3MB.6.将“学生管理数据库”更名为“学生管理”。7.将“学生管理”
数据库实验和参

上机实验三

1.在“学生管理数据库”中用查询分析器创建p82页的课程数据表(表名为kcb),并输入数据内容。

2.用查询分析器在student表中增加一个字段:“电话号码”, 字符型,并设置默认值为“1111111”。

3.用查询分析器删除kcb表的主键

4.用企业管理器或查询分析器修改course表,设置约束:学时>=学分*16。

5.用查询分析器修改学生管理数据库中的students_dat文件增容方式为一次增加3MB.

6.将“学生管理数据库”更名为“学生管理”。

7.将“学生管理”数据库备份到外存中。

8.将“学生管理”数据库的数据导出为excel文件,并保存在外存中。

9.为course表中的课程名建立唯一性索引。

10.将“学生管理”数据库从系统中分离出来。

11. 将“学生管理”数据库附加到企业管理器中。

上机实验四

1.分别查询学生表和学生修课表中的全部数据。

2.查询计算机系的学生的姓名、年龄。

3.查询选修了c01号课程的学生的学号和成绩。

4.查询成绩在70到80分之间的学生的学号、课程号和成绩。

5.查询计算机系年龄在18到20之间且性别为“男”的学生的姓名、年龄。

6.查询0412101号学生的修课情况。

7.查询c01号课程成绩最高的分数。

8.查询学生都选修了哪些课程,要求列出课程号。

9.查询Northwind数据库中orders表的OrderlD、CustomerID和OrderDate,并将最新    的定购日期(OrderDate)列在前边。

10.查询Northwind数据库中orders表的ShipCountry列以B,C,D,F开始且第三个字符为“a”的OrderlD、CustomerID和ShipCountry的信息。

11.查询Northwind数据库中orders表的ShipCountry列不以A,B,C,D,E,F开始且最后一个字母是“a”的OrderlD、CustomerlD和ShipCountry的信息。

12.查询学生数据库中学生的最大年龄和最小年龄。

13.查询修了c02号课程的所有学生的平均成绩、最高成绩和最低成绩。

14.统计每个系的学生人数。

15.统计每门课程的修课人数和最高分                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    

16.统计每个学生的选课门数,并按选课门数的递增顺序显示结果。

17. 查询哪些课程尚未考试。

18.列出计算机系年龄最大者及次大者的姓名。

上机实验五

19.统计各系的修课的学生总数和考试的平均成绩。

20.查询选课门数超过2门的学生的平均成绩和选课门数。

21.列出总成绩超过200分的学生,要求列出学号、总成绩。

22·查询pubs数据库的titles表中每类图书的平均价格超过12.O元的书的类型(Type)、    平均价格和最高价格,要求只计算有确定价格的图书的情况。

23·查询pubs数据库的titles表中版税(royalty)为10的每类书的平均价格。

24·查询pubs数据库的titles表中每类图书中图书的数目超过3本的图书的总价格。

25.查询选修了c02号课程的学生的姓名和所在系。.

26·查询成绩80分以上的学生的姓名、课程号和成绩,并按成绩的降序排列结果。

27.查询计算机系男生修了“数据库基础”的学生的姓名、性别、成绩。

28·查询学生的选课情况,要求列出每位学生的选课情况(包括未选课的学生),并列出学    生的学号、姓名、修课号、修课成绩。

29.列出“数据库基础”课程考试成绩前三名的学生的学号、姓名、所在系和考试成绩。

30.查询哪些学生合选了一门课程,要求列出合选课程的学生的学号和课程号。

31.查询哪些学生的年龄相同,要求列出年龄相同的学生的姓名和年龄。

上机实验六

32.查询哪些课程没有人选,要求列出课程号和课程名。

33. 查询有考试成绩的所有学生的姓名、修课名称及考试成绩,要求将查询结果放在一张    新的永久表(假设新表名为new sc)中,新表的列名分别为:Student_Name,Course_ Name,Grade。

34.分别查询信息系和计算机系的学生的姓名、性别、修课名称、修课成绩,并要求将这两个查询结果合并成一个结果集,并以系名、姓名、性别、修课名称、修课成绩的顺序显    示各列。

35.用子查询实现如下查询:    .

(1)查询选修了c01号课程的学生的姓名和所在系。   (2)查询数学系成绩80分以上的学生的学号、姓名。

(3)查询计算机系学生所选的课程名。    4)查询"VB”课程考试成绩前三名的学生的学号、姓名、所在系。

36.创建一个新表test,其结构为:(COLl,COL 2,COL 3),其中:

  COLl:整型,允许空值,

  COL2:字符型,长度为10,不允许空值,

  COL3:字符型,长度为10,允许空值,

  试写出按行插入如下数据的语句(空白处表示不提供值),并观察插入后表中的记录值。

    序号

    COLl    COL2    COL3
    (1)、

    B1
    (2)    1    BZ    C2
    (3)    2    B3
    (4)    B4    C4
37.将计算机系成绩高于80分的学生的修课情况插入到另一张表中,分两种情况实现:

  (1)在插入数据过程中建表。          (2)先建一个新表,然后再插入数据。

38.删除修课成绩小于50分的学生的修课记录

39.删除信息系修课成绩小于50、分的学生的修课记录,分别用子查询和连接查询实现。

40.将所有选修了"c01”课程的学生的成绩加10分。

41.将计算机系所有选修了“计算机应用”课程的学生的成绩加10分,分别用子查询和连接查询实现。

42.创建信息系选修了“数据库基础”课程的学生视图stv1。

43.创建计算机系的学生视图stv2.

44.查询信息系选修“数据库基础”课程且成绩在80分以上的学生姓名。

45.删除视图stv1。

46.利用视图stv2,将计算机系的学生年龄加1.

47.查询哪些学生选修了所有课程,列出学生的学号(姓名)。

48.查询哪些课程被所有的学生选修,列出课程号(名)。

49.查询同时选修了“VB”和“数据库基础”的学生姓名。

50 查询只选“VB”而没选“数据库基础”的学生姓名。

--实验三

--1

create table kcb(Cno char(4) constraint zj primary key,

                 Cname char(40),

                 Cpno char(4) constraint wj foreign key references kcb(cno),

                 Ccredit smallint); 

insert into kcb(Cno,Cname,Cpno,Ccredit)

values ('1','数据库','5',4); 

--2 

alter table Student add phone char(7) default '1111111'; 

--3 

alter table kcb drop constraint wj,zj

--4

alter table Course add check(class_hour>=Ccredit*16);

--5 

alter database 学生管理数据库 modify file(name='students_data',filegrowth=3mb);

--6 

sp_renamedb 学生管理数据库,学生管理

--7

backup database 学生管理 to disk='c\\297'

--9 

create unique index Coucno on Course(Cno);

--实验四

--1

select * from student 

select * from SC

--2

select Sname,Sage from student where Sdept='计算机系';

--3

select Sno,Grade from SC where Cno='c01';

--4

select * from SC where Grade>70 and Grade<80

--5

select Sname,Sage from student

where Sdept='计算机系' and Ssex='男' and Sage>18 and Sage<20

--6

select * from SC

where Sno='0412101'

--7

select max(Grade)max from SC

where Cno='c01'

--8

select distinct Cno

from SC

--9

select OrderID,CustomerID,OrderDate from Orders

ORDER BY OrderDate DESC

--10

select OrderID,CustomerID,ShipCountry from Orders

where ShipCountry like'B_a%' 

   or ShipCountry like'C_a%' 

   or ShipCountry like'D_a%'

   or ShipCountry like'F_a%'

--11

select OrderID,CustomerID,ShipCountry from Orders

where  ShipCountry not like'A%a'

  and  ShipCountry not like'B%a'

  and  ShipCountry not like'C%a'

  and  ShipCountry not like'D%a'

  and  ShipCountry not like'E%a'

  and  ShipCountry not like'F%a'

--12

select max(Sage)max,min(Sage)min from student

--13

select avg(Grade)avg,max(Grade)max,min(Grade)min from SC

where Cno='c02'

--14

select Sdept,count(*)renshu from student

Group by Sdept

--15

select Cno,count(*)renshu,max(Grade)maxGrade from SC

group by Cno 

--16

select Sno,count(Sno)Snum from SC

group by Sno

order by count(Sno) asc

--17

select Cno from SC 

group by Cno 

having count(Grade)=0

--18

select top 2 with ties Sname,Sage from student

where Sdept='计算机系' 

order by Sage desc

--实验五

--19

select Sdept,count(distinct student.Sno)学生总数,avg(Grade)平均成绩 from student,SC

where student.Sno=SC.Sno and Sdept in(select s1.Sdept from student s1

                                      group by s1.Sdept)

group by Sdept

--20

select avg(Grade)avg,count(*)menshu from SC

group by Sno

having count(*)>2

--21

select Sno,sum(Grade)sum from SC

group by Sno

having sum(Grade)>200

--22

select type,avg(price)avg1,max(price)max1 from titles

where price>12 and price is not null

group by type

--23

select type,avg(price)avg1 from titles

where royalty=10

group by type

--24

select type,sum(price) from titles

group by type

having count(*)>3

--25

select Sname,Sdept from SC,student

where student.Sno=SC.Sno and Cno='c02'

--26

select Sname,Cno,Grade from SC,student

where student.Sno=SC.Sno and Grade>80

--27

select Sname,Ssex,Grade from student,Course,SC

where Course.Cno=SC.Cno and SC.Sno=student.Sno and Sdept='计算机系' and Ssex='男' and Cname='数据库基础'

--28

select student.Sno,Sname,Cno,Grade 

from student left  join SC on student.Sno=SC.Sno

--29

select top 3 with ties student.Sno,Sname,Sdept,Grade from SC,student,Course

where Course.Cno=SC.Cno and SC.Sno=student.Sno and Cname='数据库基础'

order by Grade desc

--30

select Sno,Cno from SC 

where Cno in(select s1.Cno from SC s1 

             group by s1.Cno

having count(s1.Cno)>=2)

order by Cno

--31

select Sname,Sage from student

where Sage in(select s1.Sage from student s1

              group by s1.Sage

having count(s1.Sage)>=2)

order by Sage

--实验六

--32

select Course.Cno,Cname from SC,Course

where Course.Cno=SC.Cno and Course.Cno not in(select distinct Cno from SC)

--33

create table new_sc(Student_Name char(10),

                    Course_Name char(20),

                    Grade smallint);

insert 

into new_sc(Student_Name,Course_Name,Grade)

select Sname,Cname,Grade from SC,student,Course

where Course.Cno=SC.Cno and SC.Sno=student.Sno and Grade is not null

--34

select Sdept,Sname,Ssex,Cname,Grade from SC,student,Course

where Course.Cno=SC.Cno and SC.Sno=student.Sno and Sdept='信息系'

union

select Sdept,Sname,Ssex,Cname,Grade from SC,student,Course

where Course.Cno=SC.Cno and SC.Sno=student.Sno and Sdept='计算机系'

--35

--(1)

select Sname,Sdept from student

where Sno in(select Sno from SC

             where Cno='c01')

--(2)

select Sno,Sname from student

where Sdept='数学系' and Sno in(select Sno from SC

where Grade>80)

--(3)

select Cname from Course

where Cno in(select Cno from SC

             where Sno in(select Sno from student

                          where Sdept='计算机系')

             )

--(4)

select Sno,Sname,Sdept from  student

where Sno in(select top 3 with ties Sno from SC

             where Cno in(select Cno from Course

                          where Cname='VB')

             order by Grade desc

             )

--36

create table test(COL1 int,

                  COL2 char(10) not null,

                  COL3 char(10)

                  );

insert into test(COL1,COL2,COL3 )

values(null,'B2','');

insert into test(COL1,COL2,COL3 )

values(1,'B2','C2');

--37

--(1)

select Sname,Sdept,Cno,Grade into s1

from student,SC

where student.Sno=SC.Sno and Sname='计算机系' and Grade>80

--(2)

create table new_sc1(st_name char(10),

                     st_sdept char(20),

                     sc_cno char(10),

                     sc_grade int);

insert into

new_sc1(st_name,st_sdept,sc_cno,sc_grade)

select Sname,Sdept,Cno,Grade from SC,student

where SC.Sno=student.Sno and Sdept='计算机系' and Grade>80

--38

delete from SC where Grade<50

--39

--(1)

delete from SC where Grade<50 and Cno in(select Cno from Course

                                         where Cname='信息系 ') 

--(2)

delete from SC from Course where SC.Cno=Course.Cno and Grade<80 and Cname='信息系 '

--40

update SC

set Grade=Grade+10

where Cno='c01'

--41

--(1)

update SC 

set Grade=Grade+10

where  Cno in(select Cno from Course where Cname='计算机应用') 

        and  Sno in(select Sno from student where Sdept='计算机系')

--(2)

update SC  

set Grade=Grade+10  

from Course,student where Course.Cno=SC.Cno and SC.Sno=student.Sno and Cname='计算机应用'and Sdept='计算机系'                                                      

--42

create view stv1

as

select student.Sno,Sname,Sage from student,SC,Course

where Course.Cno=SC.Cno and SC.Sno=student.Sno and Sdept='计算机系' and Cname='数据库基础 '

--43

create view stv2

as

select * from student where Sdept='计算机系'

--44

select Sname from student,SC,Course

where Course.Cno=SC.Cno and SC.Sno=student.Sno and Sdept='信息系' and Cname='数据库基础 ' and Grade>80

--45

drop view stv1

--46

update stv2

set Sage=Sage+1

where Sdept='计算机系'

--47

select Sname from student

where not exists(select * from Course 

                 where not exists(select * from SC

                                  where Course.Cno=SC.Cno and SC.Sno=student.Sno)

                 )

--48

select Cno,Cname from Course

where not exists(select * from SC 

                 where not exists(select * from student

                                  where Course.Cno=SC.Cno and SC.Sno=student.Sno)

                 )

--49

select Sname from student,SC,Course

where Course.Cno=SC.Cno and student.Sno=SC.Sno and Cname='VB ' 

      and student.Sno in(select Sno from SC where Cno in(select Cno from Course where Cname='数据库基础'))  

--50

select Sname from student,SC,Course

where Course.Cno=SC.Cno and student.Sno=SC.Sno and Cname='VB ' 

      and student.Sno  not in(select Sno from SC where Cno in(select Cno from Course where Cname='数据库基础')) 

文档

数据库实验和参

数据库实验和参上机实验三1.在“学生管理数据库”中用查询分析器创建p82页的课程数据表(表名为kcb),并输入数据内容。2.用查询分析器在student表中增加一个字段:“电话号码”,字符型,并设置默认值为“1111111”。3.用查询分析器删除kcb表的主键4.用企业管理器或查询分析器修改course表,设置约束:学时>=学分*16。5.用查询分析器修改学生管理数据库中的students_dat文件增容方式为一次增加3MB.6.将“学生管理数据库”更名为“学生管理”。7.将“学生管理”
推荐度:
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top