当前位置:网站首页>数据库期中(二)
数据库期中(二)
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)); |
边栏推荐
- Logback custom messageconverter
- 基于Flink实时计算Demo:用户行为分析(四:在一段时间内到底有多少不同的用户访问了网站(UV))
- Flink sliding window understanding & introduction to specific business scenarios
- Spark on yarn's job submission process
- MYSQL数据库事务的隔离级别(详解)
- Dataframe of sparksql
- 李宏毅机器学习(2017版)_P1-2:机器学习介绍
- Flink1.11 多并行度watermark测试
- Golang implements AES with five encryption mode functions, encrypt encryption and decryption string output
- Scala-模式匹配
猜你喜欢

MySQL索引优化:哪些情况下需要建立索引(适合构建索引的几种情况)

李宏毅机器学习(2017版)_P21:卷积神经网络CNN

吴恩达深度学习系列教学视频学习笔记(一)——用于二分类的logistic回归函数

李宏毅机器学习(2017版)_P6-8:梯度下降

adb.exe已停止工作 弹窗问题

基于Flink实时计算Demo:用户行为分析(四:在一段时间内到底有多少不同的用户访问了网站(UV))

Game project export AAB package upload Google tips more than 150m solution

基于Flink实时项目:用户行为分析(二:实时流量统计)

SQL学习(3)——表的复杂查询与函数操作

PlantCV中文文档
随机推荐
不止直播:腾讯云直播MLVB 插件除了推流/拉流还有哪些亮眼功能
最长公共子串
Understanding of Flink interval join source code
Flink 1.15 local cluster deployment standalone mode (independent cluster mode)
What are the necessary functions of short video app development?
Wu Enda's in-depth learning series teaching video learning notes (I) -- logistic regression function for binary classification
New experience of mlvb cloud live broadcast: millisecond low latency live broadcast solution (with live broadcast performance comparison)
Pytorch tensor data basic operation
Redisson 工作原理-源码分析
FaceNet
Scala pattern matching
The difference between forward and redirect
微信大量下架数字藏品相关小程序:NFT产品究竟是未来还是陷阱?
Flinksql multi table (three table) join/interval join
Spark源码学习——Data Serialization
redis——缓存雪崩、缓存穿透、缓存击穿
MYSQL中的行锁升级表锁的原因
基于Flink实时项目:用户行为分析(二:实时流量统计)
Flink1.11 write MySQL test cases in jdcb mode
腾讯云直播插件MLVB如何借助这些优势成为主播直播推拉流的神助攻?