2018-06-03-oracleTest

简介: 版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/kese7952/article/details/80558881 Oracle实验练习题查询Student表中的所有记录的Sname、Ssex和Class列。
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/kese7952/article/details/80558881

Oracle实验练习题

  1. 查询Student表中的所有记录的Sname、Ssex和Class列。

    select sname ,sex,sclass from student;
  2. 查询教师所有的单位即不重复的Depart列。

    select distinct t.depart from teacher t;
  3. 查询Student表的所有记录

    select * from student;
  4. 查询Score表中成绩在60到80之间的所有记录。

    select * from score sc where degree between 60 and 80; 
    select * from score sc where degree >= 60 and degree <= 80; 
  5. 查询Score表中成绩为85,86或88的记录。

    select * from score  where degree in (85,86,88);
    select * from score  where degree = '85' or degree ='86'or degree = '88');
  6. 查询Student表中“95031”班或性别为“女”的同学记录

    select * from student  where sclass ='95031' and ssex= '女';
  7. 以Class降序查询Student表的所有记录。

    select * from student order by sclass desc;
  8. 以Cno升序、Degree降序查询Score表的所有记录

    select * from score sc order by sc.sno asc ,sc.degree desc;
  9. 查询“95031”班的学生人数。

    select s.sclass 总人数 from student s where sclass = '95031';
  10. 查询Score表中的最高分的学生学号和课程号。(子查询或者排序)

    select sc.sno,sc.cno from score sc order by degree desc;
  11. 查询Score表中至少有5名学生选修的并以3开头的课程的平均分数。

    select cno, avg(degree) from score where cno like '3%' group by cno having count(1)>=5 ;
  12. 查询所有学生的Sname、Cno和Degree列

    select s.sname,sc.cno,sc.degree from score sc,student s where sc.sno=s.sno;
  13. 查询所有学生的Sno、Cname和Degree列

    select s.sno,t.degree,c.cname from score sc,student s,course c where sc.sno=s.sno and sc.cno =c.cno;
  14. 查询所有学生的Sname、Cname和Degree列

    select s.sname,t.degree,c.cname from score t,student s,course c where t.sno=s.sno and t.cno =c.cno;
  15. 查询“张旭“教师任课的学生成绩。

    select t.tno,c.cno,c.cname,s.degree from TEACHER t  
    join course c on t.tno =c.tno
    join score s on c.cno =s.cno where t.tname='张旭';    
  16. 查询选修某课程的同学人数多于5人的教师姓名。

    select tname from teacher e 
     join course c on e.tno=c.tno
     join(select cno from SCORE  group by cno having count(cno)>5) t on c.cno=t.cno   ;
  17. 查询和学号为108的同学同年出生的所有学生的Sno、Sname和Sbirthday列。

    select sno,sname,sbirthday from student where to_char(sbirthday,'yyyy')=(select to_char(t.sbirthday,'yyyy') from STUDENT t 
    where sno='108') 
  18. 查询和学号为108的同学同年出生的所有学生的Sno、Sname和Sbirthday列。

    select cno from SCORE t where degree>85 group by cno
  19. 查询出“计算机系“教师所教课程的成绩表

    select t.sno,t.cno,t.degree from SCORE t 
    join course c on t.cno=c.cno
    join teacher e on c.tno=e.tno where e.depart ='计算机系';
  20. 查询“计算机系”与“电子工程系“不同职称的教师的Tname和Prof

    select tname,prof from teacher where depart ='电子工程系' and prof 
    not in(select prof from teacher where depart ='计算机系')
    or depart ='计算机系' and prof not in(select prof from teacher where depart='电子工程系');
    select tname,prof from teacher where prof not in(
    select a.prof from
    (select prof from teacher where depart ='计算机系') a 
    join 
    (select prof from teacher where depart='电子工程系') b
    on a.prof =b.prof )
    

    作者: 杨校

    出处: https://blog.csdn.net/kese7952

    分享是快乐的,也见证了个人成长历程,文章大多都是工作经验总结以及平时学习积累,基于自身认知不足之处在所难免,也请大家指正,共同进步。

    本文版权归作者所有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出, 如有问题, 可邮件(397583050@qq.com)咨询。

目录
相关文章
|
4月前
|
安全 算法
Higres 改造传统网关适合什么场景
Higres 改造传统网关适合什么场景
|
4月前
|
SQL 搜索推荐 分布式数据库
用户画像建设
用户画像建设
165 0
|
4月前
|
存储 机器学习/深度学习 编译器
ARM汇编快速入门
ARM汇编快速入门
264 0
|
4月前
|
算法 Java 数据中心
分布式ID生成系统之雪花算法详解
在当今的云计算和微服务架构盛行的时代,分布式系统已成为软件开发的重要组成部分。随着系统规模的扩大和业务的复杂化,对数据一致性和唯一性的要求也越来越高,尤其是在全局唯一标识符(ID)的生成上。因此,分布式ID生成系统应运而生,成为保证数据唯一性和提高系统可扩展性的关键技术之一。雪花算法(Snowflake)是Twitter开源的一种算法,用于生成64位的全局唯一ID,非常适用于分布式系统中生成唯一标识符。下面我们将深入探讨雪花算法的原理、结构和实现方式。
217 2
 分布式ID生成系统之雪花算法详解
|
4月前
|
SQL 关系型数据库 MySQL
Flink CDC产品常见问题之oracel cdc 的延时很大如何解决
Flink CDC(Change Data Capture)是一个基于Apache Flink的实时数据变更捕获库,用于实现数据库的实时同步和变更流的处理;在本汇总中,我们组织了关于Flink CDC产品在实践中用户经常提出的问题及其解答,目的是辅助用户更好地理解和应用这一技术,优化实时数据处理流程。
|
C语言
51单片机串口使用
51单片机串口使用
211 0
|
数据采集 机器学习/深度学习 算法
数据治理之参考数据与主数据管理
最近凑巧参与了一次某行业的业务共创会议,期间讨论到了主数据系统,还有我们该如何参与主数据系统建设的话题。说实话,我一直以为我不会有机会参与到主数据与参考数据系统的话题中去,所以,又去把DAMA的书籍翻了翻。顺便也重新思考了一下主数据与参考数据这个数据治理的课题。
2693 1
数据治理之参考数据与主数据管理
|
11月前
|
JavaScript Windows 内存技术
node版本管理神器nvm安装使用教程(Windows11版本)
node版本管理神器nvm安装使用教程(Windows11版本)
177 0
|
JavaScript
JS 获取后七天内的日期,包括当前时间
JS 获取后七天内的日期,包括当前时间
361 0
|
SQL 存储 算法
Mysql加锁流程详解
Mysql加锁流程详解
677 0
Mysql加锁流程详解