温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

软件测试-常见数据库笔试题

发布时间:2020-10-24 23:52:02 来源:网络 阅读:2857 作者:易瑞云测试 栏目:软件技术

一、

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')

  1. 将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)

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI