山东大学软件学院数据库系统实验四
文章目录
- 一、实验时间
- 二、实验题目
一、实验时间
2021年4月25日星期六,第8周,补周二的课
二、实验题目
1.将pub用户下表student_41及数据复制到主用户的表test4_01中,使用alter table语句为表增加列:“总成绩:sum_score”。
使用update语句,利用pub.student_course、pub.course,统计 “总成绩”;
create table test4_01
as select *
from pub.student_41;
alter table test4_01
add sum_score int;
update test4_01 t
set sum_score = (select sum(score) from pub.student_course sc where t.sid = sc.sid)
2.将pub用户下表student_41及数据复制到主用户的表test4_02中,使用alter table语句为表增加列"平均成绩:avg_score" (小数点后保留1位)。
利用pub.student_course、pub.course,统计"平均成绩",四舍五入到小数点后1位
create table test4_02
as select *
from pub.student_41
alter table test4_02
add avg_score decimal(5,1)
update test4_02 t
set avg_score = (select avg(score) from pub.student_course sc where t.sid = sc.sid)
3.将pub用户下表student_41及数据复制到主用户的表test4_03中,使用alter table语句为表增加列:“总学分:sum_credit”。
使用update语句,利用pub.student_course、pub.course,统计 “总学分”;
这是需要注意:成绩及格才能够计算所得学分。
create table test4_03
as select *
from pub.student_41
alter table test4_03
add sum_credit int
update test4_03 a
set sum_credit = (select sum(credit) from (select * from((select sid,cid,max(score) score from pub.student_course group by sid,cid) x join pub.course y on x.cid = y.cid) where score>=60) b where b.sid = a.sid);
4.将pub用户下表student_41及数据复制到主用户的表test4_04中。
根据列院系名称dname到pub.department找到对应院系编号did,将对应的院系编号回填到院系名称列dname中,如果表中没有对应的院系名称,则列dname中内容不变仍然是原来的内容。
create table test4_04 as select * from pub.student_41
update test4_04 t set dname = (select did from pub.department d where t.dname = d.dname) where dname in(select a.dname from pub.department a where a.dname = t.dname)
5. 将pub用户下表student_41及数据复制到主用户的表test4_05中,使用alter table语句为表增加4个列:“总成绩:sum_score”、 “平均成绩:avg_score”、“总学分:sum_credit”、"院系编号:did varchar(2) “。
(1) 利用pub.student_course、pub.course,统计 “总成绩”;
(2) 利用pub.student_course、pub.course,统计"平均成绩”,四舍五入到小数点后1位;
(3) 利用pub.student_course、pub.course,统计 “总学分”;
(4) 根据院系名称到pub.department和pub.department_41中,找到对应编号,填写到院系编号中,如果都没有对应的院系,则填写为00。
create table test4_05 as select * from pub.student_41
alter table test4_05 add sum_score int
alter table test4_05 add avg_score decimal(5,1)
alter table test4_05 add sum_credit int
alter table test4_05 add did varchar2(2)
update test4_05 t
set sum_score = (select sum(score) from pub.student_course sc where t.sid = sc.sid)
update test4_05 t
set avg_score = (select avg(score) from pub.student_course sc where t.sid = sc.sid)
update test4_05 a
set sum_credit = (select sum(credit) from (select * from((select sid,cid,max(score) score from pub.student_course group by sid,cid) x join pub.course y on x.cid = y.cid) where score>=60) b where b.sid = a.sid);
update test4_05
set did = '00'
update test4_05 t set did =
((select did from pub.department d1 where t.dname = d1.dname)
union
(select did from pub.department_41 d2 where t.dname = d2.dname))
where t.dname in
(select dname from pub.department d1 union select dname from pub.department_41)
6.将pub用户下的Student_42及数据复制到主用户的表test4_06中,对表中的数据进行整理,修复那些不规范的数据:
剔除姓名列中的所有空格;
create table test4_06 as select * from pub.student_42
update test4_06 t1
set name = (select translate(name,'/ ','/') from test4_06 t2 where t1.sid = t2.sid)
7.对表中的数据进行整理,修复那些不规范的数据:
对性别列进行规范(需要先确定哪些性别数据不规范,也就是那些和大多数不一样的就是不规范的);
create table test4_07 as select * from pub.student_42
update test4_07 t1 set sex = (select translate(sex,'/性','/') from test4_07 t2 where t1.sid = t2.sid)
update test4_07 t1
set sex = (select translate(sex,'/ ','/') from test4_07 t2 where t1.sid = t2.sid)
8.将pub用户下的Student_42及数据复制到主用户的表test4_08中,对表中的数据进行整理,修复那些不规范的数据:
对班级列进行规范(需要先确定哪些班级不规范)。
create table test4_08 as select * from pub.student_42
update test4_08 t1
set class = (select translate(class,'/级 ','/') from test4_08 t2 where t1.sid = t2.sid)
9.将pub用户下的Student_42及数据复制到主用户的表test4_09中,对表中的数据进行整理,修复那些不规范的数据:
年龄为空值的根据出生日期设置学生年龄(截止到2012年的年龄,即年龄=2012-出生年份),年龄不为空值的不要改变。
create table test4_09 as select * from pub.student_42
update test4_09 t
set age = 2012 - extract(year from t.birthday)
where age is null
10. 将pub用户下的Student_42及数据复制到主用户的表test4_10中,对表中的数据进行整理,修复那些不规范的数据:
(1) 剔除姓名列中的所有空格;
(2) 剔除院系名称列中的所有空格;
(3) 对性别列进行规范(需要先确定哪些性别数据不规范,也就是那些和大多数不一样的就是不规范的);
(4) 对班级列进行规范(需要先确定哪些班级不规范)。
(5) 年龄为空值的根据出生日期设置学生年龄(截止到2012年的年龄,即年龄=2012-出生年份),年龄不为空值的不要改变。
create table test4_10 as select * from pub.student_42
update test4_10 t1
set name = (select translate(name,'/ ','/') from test4_10 t2 where t1.sid = t2.sid)
update test4_10 t1
set dname = (select translate(dname,'/ ','/') from test4_10 t2 where t1.sid = t2.sid)
update test4_10 t1
set sex = (select translate(sex,'/性','/') from test4_10 t2 where t1.sid = t2.sid)
update test4_10 t1
set sex = (select translate(sex,'/ ','/') from test4_10 t2 where t1.sid = t2.sid)
update test4_10 t1
set class = (select translate(class,'/级 ','/') from test4_10 t2 where t1.sid = t2.sid)
update test4_10 t
set age = 2012 - extract(year from t.birthday)
where age is null
山东大学软件学院数据库系统实验四相关推荐
- 山东大学软件学院数据库系统实验八、九
文章目录 一.实验时间 二.实验题目 一.实验时间 2021年5月25日星期二,13周 二.实验题目 实验八.数据修改的提交和回退.实体授权 一. 实验内容 启动两个不同浏览器,firefox登录主账 ...
- 山东大学软件学院数据库系统实验五
文章目录 一.实验时间 二.实验题目 一.实验时间 2021年5月4日星期二,第10周 二.实验题目 1. 在学生表pub.student中统计名字(姓名的第一位是姓氏,其余为名字,不考虑复姓)的使用 ...
- 山东大学 2020级数据库系统 实验四
What's more 山东大学 2020级数据库系统 实验一 山东大学 2020级数据库系统 实验二 山东大学 2020级数据库系统 实验三 山东大学 2020级数据库系统 实验四 山东大学 202 ...
- 太原理工大学软件学院数据库实验四(2021.4.26)
太原理工大学软件学院数据库实验四(2021.4.26) -- (1)创建Student 表 CREATE TABLE Student ( Sno CHAR(8) PRIMARY KEY, Sname ...
- 山东大学软件学院数据结构实验报告及实验代码(全)
实验大纲: https://pan.baidu.com/s/16X4z9vbJzR7D-UlTyMLjgg 提取码:g29t 内容为2019级的实验大纲,每年基本不变.平台具有查重功能,所以建议大家自 ...
- java实验四云南大学_云南大学软件学院Java实验四
云南大学软件学院Java实验四 云南大学软件学院 实 验 报 告 姓名: 王定欢 学号: 班级: 日期: 2016.10.13 成绩: JAVA实验四 一. 实验目的: Fundamental Pro ...
- 山东大学软件学院数据库系统2022年春期末考试
山东大学软件学院数据库系统2022年春期末考试 时间:2022年6月27日 8:30-10:30 试卷满分:70分 简答题(6题*4分 = 24分) 在银行转账这一事务中,(1)a = a-100;( ...
- 山东大学软件学院数据库实验1-9
SDU 数据库系统实验 实验一 1-1创建test1_student表 1-2创建test1_course表 1-3创建teset1_student_course表 1-4表test1_student ...
- 山东大学软件学院面向对象实验——排序
文章目录 一.写在最前面 二.题目要求 三.项目截图及录屏 四.具体功能的实现 4.1 动态演示功能 4.2 对象排序功能 4.3 单步回退功能 4.4 二级下拉框的实现 4.5 界面美化的实现 五. ...
最新文章
- 即使被拖库,也可以保证密码不泄露
- 超越RMI,高效Java remote调用
- openssl与cryptoAPI交互AES加密解密
- DigSci科学数据挖掘大赛:如何在3天内拿下DigSci亚军
- vue 非es6 写法怎么按须加载_Vue源码必学指南:flow(语法检查)以及rollup(模板打包)...
- 华为鸿蒙汽车自动驾驶,华为鸿蒙车机OS现身,自动驾驶再进化(一)
- 【连载】如何掌握openGauss数据库核心技术?秘诀三:拿捏存储技术(5)
- 数据挖掘:数据清洗、转换和消减
- j2ee中的2什么意思
- Kotlin的魔能机甲——KtArmor插件篇(二)
- iOS人脸识别(CoreImage)
- wps压缩word文档方法
- REST Assured 使用详解
- 热衷于摸鱼的大一新生
- Realm JavaScript
- 物联网模块开发:全面助力万物物联,开启物联网时代
- oracle禁用系统用户登录,关闭系统 - 在 x86 平台上引导和关闭 Oracle Solaris
- 软件------关于spacedesk分屏软件的使用说明(包括下载和具体启动方式)
- 电脑端微信如何清空聊天记录
- OddBall-图异常点检测
热门文章
- 黄光CdTe碲化镉量子点(基团:氨基)
- Shell+VCS学习3---VCS命令
- one piece_娜美_01
- 转载:教你用Word批量生成带照片的准考证。
- 两节串联升压充电锂电池芯片,带NTC-ZCC6982 V1
- 成都地铁,生活一脉--成都进入轨道时代
- 精选几个bootstrap后端框架模板,值得收藏!
- Redis未授权访问漏洞复现(三种方式)
- ofbiz mysql_OFBIZ 10.04 开发环境搭建(ofbiz+mysql+eclipse)
- PADS 转allegro 17.2