一些高难度的SQL面试题.doc_第1页
一些高难度的SQL面试题.doc_第2页
一些高难度的SQL面试题.doc_第3页
一些高难度的SQL面试题.doc_第4页
全文预览已结束

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1.根据如下表的查询结果,那么以下语句的结果是(知识点:not in/not exists null)以下的null代表真的null.SQL select * from usertable;USERID USERNAME -1 user12 null3 user34 null5 user56 user6SQL select * from usergrade;USERID USERNAME GRADE- - -1 user1 902 null 807 user7 808 user8 90执行语句:select count(*) from usergrade where username not in (select username from usertable);select count(*) from usergrade g where not exists(select null from usertable t where t.userid=g.userid and t.username=g.username);结果为:语句1( 0 ) 语句2 ( 3 )A: 0 B:1 C:2 D:3 E:NULL2. 在以下的表的显示结果中,以下语句的执行结果是(知识点:in/exists rownum)SQL select * from usertable;USERID USERNAME -1 user12 user23 user34 user45 user5SQL select * from usergrade;USERNAME GRADE- -user9 90user8 80user7 80user2 90user1 100user1 80执行语句Select count(*) from usertable t1 where username in(select username from usergrade t2 where rownum =1);Select count(*) from usertable t1 where exists(select x from usergrade t2 where t1.username=t2.username and rownum =1);以上语句的执行结果是:( ) ( )A: 0 B: 1 C: 2 D: 3根据以下的在不同会话与时间点的操作,判断结果是多少,其中时间T1原始表记录为;select * from emp;EMPNO DEPTNO SALARY 100 1 55101 1 50select * from dept;DEPTNO SUM_OF_SALARY -1 1052 可以看到,现在因为还没有部门2的员工,所以总薪水为null,现在,有两个不同的用户(会话)在不同的时间点(按照特定的时间顺序)执行了一系列的操作,那么在其中或最后的结果为:time session 1 session2 - T1 insert into empvalues(102,2,60)T2 update emp set deptno =2where empno=100T3 update dept set sum_of_salary =(select sum(salary) from empwhere emp.deptno=dept.deptno)where dept.deptno in(1,2);T4 update dept set sum_of_salary =(select sum(salary) from empwhere emp.deptno=dept.deptno)where dept.deptno in(1,2);T5 commit;T6 select sum(salary) from emp group by deptno;问题一:这里会话2的查询结果为:T7 commit;=到这里为此,所有事务都已完成,所以以下查询与会话已没有关系=T8 select sum(salary) from emp group by deptno;问题二:这里查询结果为T9 select * from dept;问题三:这里查询的结果为问题一的结果( ) 问题二的结果是( ) 问题三的结果是( )A: B:- -1 50 1 502 60 2 55C: D:- -1 50 1 1152 115 2 50E: F:- -1 105 1 1102 60 2 55有表一的查询结果如下,该表为学生成绩表(知识点:关联更新)select id,grade from student_gradeID GRADE 1 502 403 704 805 306 90表二为补考成绩表select id,grade from student_makeupID GRADE 1 602 805 60现在有一个dba通过如下语句把补考成绩更新到成绩表中,并提交:update student_grade s set s.grade =(select t.grade from student_makeup twhere s.id=t.id);commit;请问之后查询:select GRADE from student_grade where id = 3;结果为:A: 0 B: 70 C: null D: 以上都不对根据以下的在不同会话与时间点的操作,判断结果是多少,其中时间T1session1 session2 -T1 select count(*) from t;显示结果(1000)条T2 delete from t where rownum =100;T3 begind

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论