QUESTION
1.自我检测问题
1.什么是数据库?
2.数据库的特点?
3.哪几种数据类型
4.数据库有几种语句?具体包含哪些?
5.SQL规范
6.何时存放图片到数据库?
7.什么是自链接,内连接?
8.什么是左外连接,右外连接?
9.什么是多行子表?单行子表?
10.什么是分页?如何?
11.如何插入百万数据?
12.如何删除重复的记录?
13.like中 -,%的作用?
14.order by..asc/desc?
15.几种约束条件?
16.”与null的区别?
17.alter的使用?
18.如何备份和恢复?
19.如何备份表?
20.pc一共多少端口?具体有哪些?
21.什么是JDBC?什么是ODBC?
22.Statement和PreparedStatement区别
23.java操作具体代码?
24.group by, having作用?其余还有哪些知识点?
25.组合键的使用
26.什么是聚合函数?
27.exists是什么?
28.删除语句?
29.SQL操作符有哪些?
2.实例检测
2.1
Student(Sid,Sname,Sage,Ssex) 学生表 学号,姓名,年龄,性别
Course(Cid,Cname,Tid) 课程表 课号,课程名字,教师编号
Score(Sid,Cid,Score) 成绩表 学号,课号,成绩
Teacher(Tid,Tname) 教师表 教师编号,名字
问题:
题号 | Content |
---|---|
1、 | 查询“001”课程比“002”课程成绩高的所有学生的学号; |
2、 | 查询平均成绩大于60分的同学的学号和平均成绩; |
3、 | 查询所有同学的学号、姓名、选课数、总成绩; |
4、 | 查询姓“李”的老师的个数; |
5、 | 查询没学过“冒晓燕”老师课的同学的学号、姓名; |
6、 | 查询学过“001”并且也学过编号“002”课程的同学的学号、姓名 |
ANSWER:
1.
-- 1.
select t1.Sid from (select * from Score where score.cid = '001') t1 , (select * from Score where score.cid = '002') t2
where (t1.Sid = t2.Sid)and(t1.scr>t2.scr)
2.
-- 2.
select sid,AVG(scr) from score group by sid having AVG(scr)>60
3.
-- 3. 第一种正确,第二种错误,分析原因。理解left join
select student.sid, student.sname,count(score.cid),SUM(score.scr)
from student left join score on student.sid = score.sid group by student.sid, sname
select student.sid, student.sname count(score.cid),SUM(score.scr)
from score left join student on student.sid = score.sid group by student.sid, student.sname
4.
select tname from teacher where teacher.tname like '李%'
5.
select distinct student.sid, student.sname from student
where student.sid not in
(select score.sid from score, course, teacher where teacher.tname = '冒晓燕' and teacher.tid=course.tid and course.cid=score.cid)
6.
select student.sid, student.sname from student , score a ,score b group by b.cid,a.cid,a.sid,b.sid,student.sid,student.sname
having (b.sid=student.sid and a.sid=student.sid and a.cid = '001' and b.cid='002')
---方法二,使用exists
select Student.Sid,Student.Sname from Student,Score
where Student.Sid=Sscore.Sid and Score.Cid='001'and
exists( Select * from Score as Score2 where Score2.Sid=Score.Sid and Score2.Cid='002');
2.2面试题151207
1.
自动编号 学号 姓名 课程编号 课程名称 分数
1 2005001 张三 0001 数学 69
2 2005002 李四 0001 数学 89
3 2005001 张三 0001 数学 69
删除除了自动编号不同, 其他都相同的学生冗余信息
2.
一个叫 team 的表,里面只有一个字段name, 一共有4 条纪录,分别是a,b,c,d, 对应四个球对,现在四个球对进行比赛,用一条sql 语句显示所有可能的比赛组合.
2.2-answer
1.
delete from mytable where 自动编号 not in(select min(自动编号) from mytable group by 学号,姓名,课程编号,课程名称,分数)
2.要注意a b和b a是相等的
select * from team t1, team t2 where t1.name < t2.name