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 )

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

目录
相关文章
|
人工智能 自然语言处理 运维
AIGC系列文章汇总
AIGC系列文章汇总(2024年3月8日更新)
4135 4
AIGC系列文章汇总
|
数据中心
SFP+ DAC高速线缆与10G光模块,谁才是10G网络的最佳选择?
数据中心网络从最初的100M,1G,10G,到40G和100G,高速以太网的发展从未停止。10G以太网(IEEE802.3ae)的标准于2002年批准,在10G网络中,工程师在布线中需要考虑选择光纤还是铜缆,大家都希望选择一个性价比高的方案。
3327 0
|
2月前
|
人工智能 测试技术 Apache
通义千问 Qwen3.8 系列重磅开源:2.4万亿参数旗舰与“轻量级”Flash 齐发,重塑 AI 开发格局
阿里通义实验室开源Qwen3.8系列:2.4万亿参数旗舰版突破性能极限,轻量Flash版训练成本降90%、6B参数即达顶尖水平,全系Apache 2.0协议开放,支持私有部署与商用,推动国产大模型迈入普惠智能新纪元。(239字)
695 0
|
5月前
|
人工智能 数据可视化 数据挖掘
Harness工具是什么?Harness可为AI编程工具扩展联网搜索、代码解释器、网页抓取等能力
Harness是阿里云百炼Token Plan为Qwen系列模型(如Qwen3.8-Max-Preview)内置的增强工具集,支持联网搜索、代码解释器、网页抓取、文搜图、图搜图等能力,按调用次数计费,从套餐Credits中抵扣,开箱即用,无需额外配置。在阿里云百炼官网:https://t.aliyun.com/U/fPVHqY 免费领取千万Tokens
|
10月前
|
索引 Perl
awk高级用法——内置变量、函数与进阶技巧
本文深入讲解awk进阶核心:内置变量(NR/FNR/NF/FS/OFS/FILENAME/ARGC/ARGV等)与内置函数(length/substr/index/gsub等),涵盖行字段统计、多文件处理、动态分隔符、字符串操作等高频场景,配丰富实操示例,助你从入门迈向精通。
|
安全 IDE Java
Spring 的@FieldDefaults和@Data:Lombok 注解以实现更简洁的代码
本文介绍了如何在 Spring 应用程序中使用 Project Lombok 的 `@Data` 和 `@FieldDefaults` 注解来减少样板代码,提升代码可读性和可维护性,并探讨了其适用场景与限制。
471 0
Spring 的@FieldDefaults和@Data:Lombok 注解以实现更简洁的代码
|
8月前
|
人工智能 弹性计算 运维
阿里云发布 Agentic OS:首个面向 Agent 的操作系统
2026年3月,阿里云发布全球首款面向AI Agent的操作系统Agentic OS。它以“Agent为用户主体”,通过原生Skill封装、Copilot Shell交互、AgentSecCore全链路安全防护三大突破,显著降低Token消耗、提升部署效率与运行安全性,推动计算范式从“软件负载”迈向“智能体负载”。
|
SQL 架构师 关系型数据库
【Java架构师体系课 | MySQL篇】⑤ 索引优化实战一
本文深入解析MySQL索引优化原理,涵盖联合索引使用、覆盖索引、索引下推、filesort排序机制及trace工具分析执行计划选择等内容,并结合实际案例提供索引设计原则与SQL优化策略。
492 5
|
安全 Java Linux
Could not connect to SMTP host: smtp.***.com, port: 465, response: -1
Could not connect to SMTP host: smtp.***.com, port: 465, response: -1
1444 0
|
存储 Linux 数据安全/隐私保护
确定CentOS系统分区表类型(MBR或GPT)
以上方法均能够帮助用户准确地识别出CentOS下连接硬件所应用得具体磁盘标准,并根据实际需求做进一步处理与管理工作。
1653 0