软件测试-常见数据库笔试题
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了软件测试-常见数据库笔试题相关的知识,希望对你有一定的参考价值。
一、
1.新建表 test
id varchar2(20)
name varchar2(20)
addr varchar2(50)
score number
create table test
(id varchar2(20),
name varchar2(20),
addr varchar2(50),
score number
)
2.给id增加主键约束
alter table test add constraint pk_id primary key(id)
3.查询出分数大于60分的人员,并按分数降序进行排列
select * from test where score>60 order by score desc
4.新增数据 001 zhangsan shenzhen 80
insert into test(id,name,addr,score) values (‘001‘,‘zhansgan‘,‘shenzhen‘,‘80‘)
- 将zhangsan的分数修改成60
update test set score=60 where name=‘zhangsan‘
7.删除zhangsan的信息
delete from test where name=‘zhangsan‘
二、
Student(S#,Sname,Sage,Ssex) 学生表
Course(C#,Cname,T#) 课程表
SC(S#,C#,score) 成绩表
Teacher(T#,Tname) 教师表
问题:
1、查询平均成绩大于60分的同学的学号和平均成绩; avg
select s#,avg(score) from sc where (select avg(score) from sc)>60 group by s# ;
select s#,avg(score) from sc where group by s# having avg(score)>60;
2、查询所有同学的学号、姓名、选课数、总成绩;
select Student.s#,sname,count(C#),sum(score) from Student inner join sc on Student.s#=sc.s# group by Student.s#,sname
3、查询姓“李”的老师的个数;
select count(*) from teacher where tname like‘李%‘
4、查询没学过“叶平”老师课的同学的学号、姓名;
select S#,Sname from Student where s# in (select S# from sc where c# not in (select c# from Course where T#=(select T# from teacher where Tname=‘叶平‘ ))
5、查询所有课程成绩小于60分的同学的学号、姓名;
select S#,Sname from Student where s# not in (select S# from sc where score>60)
以上是关于软件测试-常见数据库笔试题的主要内容,如果未能解决你的问题,请参考以下文章