Oracle数据库

startcsdnle 2018-07-23 05:28:18
表名
student(S#,Sname,Sage,Ssex)学生表 S#:学号;Sname:学生姓名;Sage;学生年龄;Ssex:学生性别
Course(C#,Cname,T#) 课程表 C#:课程编号;Cname:课程名字;T#:教师编号
SC(S#,C#,score)成绩表 S#:学号;C#:课程编号;score:成绩
Teacher(T#,Tname)教师表 T#:教师编号;Tname:教师名字
问题1:查询“001”课程比“002”课程成绩高的所有学生的学号;

问题2:查询没学过“叶平”老师课的同学的学号,姓名

问题3:删除学习“叶平”老师课的SC表记录

问题4:把“sc”表中“叶平”老师教的课的成绩都更改为此课程的平均成绩



...全文
468 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
startcsdnle 2018-07-30
  • 打赏
  • 举报
回复
大神我想再问你问题,跪求大神解答

使用A charindex 函数的运用,在表store中name字段的“美”字分别在第几个位置?(写出具体sql语句)?


用上面的变量赋值表示上月第一天,上月今天,今月第一天和今天(写出具体sql语句)
startcsdnle 2018-07-30
  • 打赏
  • 举报
回复
我还有一题不知道怎么解,麻烦你帮我解决一下,多谢了
Oracle数据库表存在伪列rowid,请利用rowid编写一个sql语句,从以下记录中找到唯一记录,并将其flag列更新为Y
No name sex flag
1 张三 1 N
1 张三 1 N
1 张三 1 N
yaiger 2018-07-30
  • 打赏
  • 举报
回复
ORACLE没有charindex函数,你说的SQL SERVER。这里是ORACLE版块
yaiger 2018-07-24
  • 打赏
  • 举报
回复
后面两个sql 少写了叶平条件,下面补充了一下
delete from sc
where exists ( select 1
from course c,
teacher t
where c.t# = t.t#
and c.c# = sc.c#
and t.tname = '叶平');

update sc
set sc.score = ( select avg(score)
from sc c
where sc.c# = c.c# )
where exists ( select 1
from course c,
teacher t
where c.t# = t.t#
and c.c# = sc.c#
and t.tname = '叶平' );
yaiger 2018-07-24
  • 打赏
  • 举报
回复
大致写了一下, 没有校验。下次最好提供建表的脚本和测试数据,这样方便点

select distinct a.s#, s.sname
from sc a,
sc b,
student s
where a.s# = b.s#
and a.s# = s.s#
and a.c# = '001'
and b.c# = '002'
and a.score > b.score;

select distinct s.s#, s.sname
from sc,
student s
where sc.s# = s.S#
and not exists ( select 1
from course c,
teacher t
where c.t# = t.t#
and c.c# = sc.c#
and t.tname = '叶平') ;

delete from sc
where exists ( select 1
from course c,
teacher t
where c.t# = t.t#
and c.c# = sc.c# );

update sc
set sc.score = ( select avg(score)
from sc c
where sc.c# = c.c# )
where exists ( select 1
from course c,
teacher t
where c.t# = t.t#
and c.c# = sc.c# );

3,491

社区成员

发帖
与我相关
我的任务
社区描述
Oracle 高级技术相关讨论专区
社区管理员
  • 高级技术社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧