当前位置:网站首页>数据库期中(二)
数据库期中(二)
2022-07-26 22:42:00 【lzl_0408】
学生(学号,姓名,专业); 课程(课程号,课程名,学分); 选课(学号,课程号,成绩); |
2)写出创建课程信息的建表命令;
Create table 课程( 课程号 char(6), 课程名 varchar(30), 学分 decimal(2,1), Primary key (课程号) ); create table stu( sno char(12), name varchar(120) not null, major varchar(30) not null, Primary key (sno) ); Coment on table stu is ‘学生信息表’; Coment on column stu.sno is ‘学号’; ALTER TABLE stu COMMENT='学生信息表'; ALTER TABLE stu MODIFY sno CHAR(6) COMMENT '学号'; Create table course( cno char(7), cname varchar(30) not null, credit decimal(2,1) not null, Primary key (cno) ); Create table sc( sno char(12), cno char(7), score decimal(4,1), Primary key (sno,cno) ); |
3)写出下面查询的关系代数表达式:
a)查询出成绩小于 60 分的学生的学号;
| Select sno From sc Where score < 60; |
b)查询出成绩小于 60 分的学生的学号、姓名;
Select stu.sno, name From stu, sc Where stu.sno = sc.sno And score < 60; |
c)查询出从来没有选修课程的学生学号;
Select sno From stu Where sno not in (Select sno From sc); |
d)查询出成绩最小的学生的学号;
Select sno From sc Where score = (select min(score) from sc); |
e)查询出至少有 2 个学生选修的课程号;
Select distinct sc.cno From sc, sc s1 Where sc.cno = s1.cno and sc.sno <> s1.sno; |
Select distinct sno From sc a Where not exists ( select * From course b Where not exists ( select * from sc where sno = a.sno and cno = b.cno)); |
g)求至少选择了C001和C003两门课程的学生学号
select distinct sno from sc A where not exists( select * from course B where cno in ('C002','C003') and not exists( select * from sc C where A.sno=C.sno and B.cno=C.cno)); |
边栏推荐
- 小程序直播、连线直播、直播打赏:腾讯云移动直播组件MLVB多场景直播拓展
- pytorch张量数据基础操作
- Channel shutdown: channel error; protocol method: #method<channel. close>(reply-code=406, reply-text=
- 腾讯云直播插件MLVB如何借助这些优势成为主播直播推拉流的神助攻?
- Spark data skew solution
- Small programs related to a large number of digital collections off the shelves of wechat: is NFT products the future or a trap?
- Uni app applet app's advertising realization path: banner information flow advertising
- ContextCompat.checkSelfPermission()方法
- 不止直播:腾讯云直播MLVB 插件除了推流/拉流还有哪些亮眼功能
- SQL学习(3)——表的复杂查询与函数操作
猜你喜欢

Hidden index and descending index in MySQL 8.0 (new feature)

More than live streaming: what other eye-catching functions does Tencent cloud live mlvb plug-in have besides streaming / streaming

微信大量下架数字藏品相关小程序:NFT产品究竟是未来还是陷阱?

FaceNet

Flinksql multi table (three table) join/interval join

Use Tika to judge the file type

Flink sliding window understanding & introduction to specific business scenarios

基于Flink实时项目:用户行为分析(三:网站总浏览量统计(PV))

基于Flink实时项目:用户行为分析(一:实时热门商品统计)

智密-腾讯云直播 MLVB 插件优化教程:六步提升拉流速度+降低直播延迟
随机推荐
Use Tika to judge the file type
Rational selection of (Spark Tuning ~) operator
游戏项目导出AAB包上传谷歌提示超过150M的解决方案
Cannot find a valid baseurl for repo: HDP-3.1-repo-1
Write the changed data in MySQL to Kafka through flinkcdc (datastream mode)
MySQL索引优化:索引失效以及不适合建立索引的场景
解决rsyslog服务占用内存过高
Kubernetes 是什么 ?
基于Flink实时项目:用户行为分析(一:实时热门商品统计)
Understanding of Flink checkpoint source code
被围绕的区域
Use and cases of partitions
吴恩达深度学习系列教学视频学习笔记(一)——用于二分类的logistic回归函数
Status management in Flink
Pytorch tensor data basic operation
无重复字符的最长子串
DataNode Decommision
Flink based real-time computing Demo - Data Analysis on user behavior
使用tika 判断文件类型
redis——缓存雪崩、缓存穿透、缓存击穿