2018-06-03-oracleTest

简介: 2018-06-03-oracleTest

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

查询Student表中“95031”班或性别为“女”的同学记录

select * from student  where sclass ='95031' and ssex= '女';

以Class降序查询Student表的所有记录。

select * from student order by sclass desc;

以Cno升序、Degree降序查询Score表的所有记录

select * from score sc order by sc.sno asc ,sc.degree desc;

查询“95031”班的学生人数。

select s.sclass 总人数 from student s where sclass = '95031';

查询Score表中的最高分的学生学号和课程号。(子查询或者排序)

select sc.sno,sc.cno from score sc order by degree desc;

查询Score表中至少有5名学生选修的并以3开头的课程的平均分数。

select cno, avg(degree) from score where cno like '3%' group by cno having count(1)>=5 ;

查询所有学生的Sname、Cno和Degree列

select s.sname,sc.cno,sc.degree from score sc,student s where sc.sno=s.sno;

查询所有学生的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;

查询所有学生的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;

查询“张旭“教师任课的学生成绩。

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='张旭';    


查询选修某课程的同学人数多于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   ;

查询和学号为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') 

查询和学号为108的同学同年出生的所有学生的Sno、Sname和Sbirthday列。

select cno from SCORE t where degree>85 group by cno

查询出“计算机系“教师所教课程的成绩表

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 ='计算机系';

查询“计算机系”与“电子工程系“不同职称的教师的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 )

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

目录
相关文章
|
SQL 安全 JavaScript
基于JavaWeb的电影院在线选座订票管理系统
基于JavaWeb的电影院在线选座订票管理系统
655 0
基于JavaWeb的电影院在线选座订票管理系统
|
4月前
|
关系型数据库 MySQL Linux
通过虚拟机进行安装Centos7.0并且安装MySQL
通过虚拟机进行安装Centos7.0并且安装MySQL
78 0
|
4月前
|
SQL 存储 关系型数据库
杨校老师课题之Hive数据仓库搭建1
杨校老师课题之Hive数据仓库搭建
66 0
|
4月前
|
Oracle 安全 关系型数据库
Oracle 11G数据库安装步骤及截图操作1
Oracle 11G数据库安装步骤及截图操作
86 0
|
4月前
|
SQL 存储 关系型数据库
杨校老师课题之Hive数据仓库搭建2
杨校老师课题之Hive数据仓库搭建
42 0
|
4月前
|
SQL 数据库 数据安全/隐私保护
号称全网最快的数据库连接池HikariCP的工具类开发-HikariCPUtils
号称全网最快的数据库连接池HikariCP的工具类开发-HikariCPUtils
59 0
|
4月前
|
弹性计算 关系型数据库 MySQL
阿里云ECS如何部署并运行一个JavaWeb项目
阿里云ECS如何部署并运行一个JavaWeb项目
59 0
|
4月前
|
存储 Linux 网络安全
杨校老师课堂之云计算私有云OpenStack框架快速搭建
杨校老师课堂之云计算私有云OpenStack框架快速搭建
96 0
|
4月前
|
Java Apache Maven
杨校老师课堂之Maven下载与配置阿里云镜像
杨校老师课堂之Maven下载与配置阿里云镜像
134 0
|
4月前
|
Java Linux
杨校老师课堂之CentOS7部署开发环境Jdk1.8【Linux】
杨校老师课堂之CentOS7部署开发环境Jdk1.8【Linux】
51 0