drop table class
create table class (
classId nchar(6) primary key not null,
cName nvarchar(20)
)
insert into class
values('','自动化1班')
insert into class
values('','计算机1班'),
('','计算机2班'),
('','自动化2班') select * from class delete class where classId=''
delete class where classId=''
delete class where classId=''
delete class where classId='' update class set cName='自动化3班'
where classId=09034 alter table student
alter column classId nchar(6)not null alter table student --给student的classId属性增加一个外键
add constraint classId foreign key(classId) references class(classId) alter table student --删掉该外键约束
drop constraint classId --然后才能删掉class
drop table class select * from course
select * from score
select * from student
select * from teacher --检查学号为107的学生的课程名,任课老师
select ci.cName,ti.teaName from student as si
inner join score as sco on sco.stuId=si.stuId
inner join course as ci on ci.cId=sco.cId
inner join teacher as ti on ti.teaId=ci.teaId
where si.stuId=107 --检索王同学不学习且不助教的任课老师和课程名
select ti.teaName,ci.cName from course as ci
inner join teacher as ti on ti.teaId=ci.teaId
except (
--王同学学习的课程及任课老师
select ti.teaName,ci.cName from student as si
inner join score as sco on sco.stuId=si.stuId
inner join course as ci on ci.cId=sco.cId
inner join teacher as ti on ci.teaId=ti.teaId
where si.stuName like '王%'
union
--王同学助教的任课老师的课
select ti.teaName,ci.cName from course as ci
inner join teacher as ti on ci.teaId=ti.teaId
where ti.teaWork='助教' and ti.teaName like '王%'
) --检索至少选修两门课程的学生学号
select sco.stuId,COUNT(*) from score as sco
group by sco.stuId having COUNT(*)>1 --子查询
--按学号列出每个学生所选修课程中最高分的课程名称及其分数
select si.stuId,ci.cName,sco.score
from student as si
inner join score as sco on sco.stuId=si.stuId
inner join course as ci on ci.cId=sco.cId
inner join teacher as ti on ci.teaId=ti.teaId
where sco.score>=
(
select MAX(ssco.score) from student as ssi
inner join score as ssco on ssco.stuId=ssi.stuId
inner join course as cci on cci.cId=ssco.cId
inner join teacher as tti on cci.teaId=tti.teaId
where ssi.stuName=si.stuName
)
order by si.stuId asc

最新文章

  1. 使用gulp解决RequireJS项目前端缓存问题(一)
  2. BZOJ1856[SCOI2010]字符串
  3. android 横向滚动条
  4. .net core 学习笔记(4)-ViewComponent
  5. InnoDB为什么要使用auto_Increment
  6. MVC + EF + Bootstrap 2 权限管理系统入门级(附源码)
  7. 微信稳居Android App排行榜4月份国内榜首
  8. CCNA 6.3
  9. MySQL数据库update更新子查询
  10. 把复选框变成单选框(prop,attr的区别)
  11. C++中友元详解
  12. Java基础 -- 字符串(格式化输出、正则表达式)
  13. kafka写入hdfs
  14. 关于tomcat WEB-INF/lib下类加载顺序
  15. 低延时的P2P HLS直播技术实践
  16. vue单页面模板说明文档(3)
  17. [JVM] IDEA集成VisualVM
  18. 剑指Offer 46. 孩子们的游戏(圆圈中最后剩下的数) (其他)
  19. django by example 第四章 扩展 User 模型( model)
  20. Android通过包名启动其他应用,若该应用已启动,则直接将应用切到前台

热门文章

  1. spring-boot整合Cxf的webservice案例
  2. Android逆向之旅---Android应用的汉化功能(修改SO中的字符串内容)
  3. PWA 应用
  4. bug 自定义的json2bean的bug
  5. fine report 连接mysql (mac)
  6. English-such as, for example, include and contain
  7. 基础复习之HTML (doctype、标签语义化)
  8. HttpServletRequest 对文件上传的支持
  9. Java GC算法
  10. IPython notebook在浏览器中显示不正常的问题及解决方法