山东大学 数据库 实验四 复制表
Test4 复制表、修改表结构、修改数据(2学时)
一、 实验内容
利用oracle管理平台完成对表的结构、数据进行修改,每一个问题可以通过多个SQL语句完成。
二、 实验题目
1. 将pub用户下表student_41及数据复制到主用户的表test4_01中,使用alter table语句为表增加五个列:“总成绩:sum_score”、 “平均成绩:avg_score”(四舍五入到个位)、“总学分:sum_credit”、“院系编号:did varchar(2) ”。
使用update语句,利用pub.student_course、pub.course,统计 “总成绩”; create table test4_01 as select* from pub.student_41
alter table test4_01 add sum_score int
alter table test4_01 add avg_score numeric(5,1)
alter table test4_01 add sum_credit int
alter table test4_01 add did varchar(2)
select *from test4_01
create table test01 as select sid,sum(score) sum_score from pub.student_course group by sid
update test4_01
set sum_score=(select test01.sum_score
from test01
where test01.sid=test4_01.sid)
2. 将pub用户下表student_41及数据复制到主用户的表test4_02中,使用alter table语句为表增加五个列:“总成绩:sum_score”、 “平均成绩:avg_score”(四舍五入到个位)、“总学分:sum_credit”、“院系编号:did varchar(2) ”。
利用pub.student_course、pub.course,统计“平均成绩”;
create table test4_02 as select* from pub.student_41
alter table test4_02 add sum_score int
alter table test4_02 add avg_score numeric(5,1)
alter table test4_02 add sum_credit int
alter table test4_02 add did varchar(2)
select *from test4_02
create table test02 as select sid,avg(score) avg_score from pub.student_course group by sid update test4_02
set avg_score=(select test02.avg_score
from test02
where test02.sid=test4_02.sid)
3. 将pub用户下表student_41及数据复制到主用户的表test4_03中,使用alter table
语句为表增加五个列:“总成绩:sum_score”、 “平均成绩:avg_score”(四舍五入到个位)、“总学分:sum_credit”、“院系编号:did varchar(2) ”。
使用update语句,利用pub.student_course、pub.course,统计 “总学分”; drop table test4_03
create table test4_03 as select* from pub.student_41
alter table test4_03 add sum_score int
alter table test4_03 add avg_score numeric(5,1)
alter table test4_03 add sum_credit int
alter table test4_03 add did varchar(2)
select *from pub.course
drop table test03
create table test031 as select sid,cid,score from pub.student_course
alter table test031 add credit int
update test031
set credit=(select credit
from pub.course
where test031.cid=pub.course.cid and score>=60)
update test031
set credit=0
where score<60
create table test03 as select sid,sum(credit) sum_credit from test031
group by sid
update test4_03
set sum_credit=(select test03.sum_credit
from test03
where test03.sid=test4_03.sid)
4. 将pub用户下表student_41及数据复制到主用户的表test4_04中,使用alter table
语句为表增加五个列:“总成绩:sum_score”、 “平均成绩:avg_score”(四舍五入到个位)、“总学分:sum_credit”、“院系编号:did varchar(2) ”。
根据院系名称到pub.department或者pub.department_41中,找到对应编号,填写到院系编号中,如果都没有对应的院系,则填写为00。
drop table test4_04
drop table test04
create table test4_04 as select* from pub.student_41
alter table test4_04 add sum_score int
alter table test4_04 add avg_score numeric(5,1)
alter table test4_04 add sum_credit int
alter table test4_04 add did varchar(2)
select *from pub.department
create table test04 as select* from pub.department
insert into test04 select*from pub.department_41
update test4_04
set did=(select test04.did
from test04
where test4_04.dname=test04.dname)
where dname in(select dname from test04)
update test4_04
set did='00'
where dname not in(select dname from test04) or dname is null
update dbtest set test=4
select * from dbscore
5. 将pub用户下表student_41及数据复制到主用户的表test4_05中,使用alter table
语句为表增加五个列:“总成绩:sum_score”、 “平均成绩:avg_score”(四舍五入到个位)、“总学分:sum_credit”、“院系编号:did varchar(2) ”。
(1) 利用pub.student_course、pub.course,统计 “总成绩”;
(2) 利用pub.student_course、pub.course,统计“平均成绩”;
(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 numeric(5,1)
alter table test4_05 add sum_credit int
alter table test4_05 add did varchar(2)
update test4_05
set sum_score=(select test4_01.sum_score
from test4_01
where test4_01.sid=test4_05.sid)
update test4_05
set avg_score=(select test4_02.avg_score
from test4_02
where test4_02.sid=test4_05.sid)
update test4_05
set sum_credit=(select test4_03.sum_credit
from test4_03
where test4_03.sid=test4_05.sid)
update test4_05
set did=(select test04.did
from test04
where test04.dname=test4_05.dname)
where dname in (select dname
from test04)
update test4_05
set did='00'
where dname not in (select dname
from test04) or dname is null
update dbtest set test=4
select * from dbscore
6. 将pub用户下的Student_42及数据复制到主用户的表test4_06中,对表中的数据进
行整理,修复那些不规范的数据:
剔除姓名列中的所有空格;
select *from pub.student_42
drop table test4_06
create table test4_06 as select* from pub.student_42
update test4_06
set name=replace(name,' ','')
7. 将pub用户下的Student_42及数据复制到主用户的表test4_07中,对表中的数 …… 此处隐藏:4135字,全部文档内容请下载后查看。喜欢就下载吧 ……
相关推荐:
- [小学教育]四年级综合实践活动课《衣物的洗涤》教
- [小学教育]2014半年工作总结怎么写
- [小学教育]20世纪外国文学专题综合试题及答案
- [小学教育]TS_1循环使用催化丙烯环氧化反应研究
- [小学教育]最实用的考勤签到表(上下班签到表)
- [小学教育]气候与生态建筑——以新疆民居为例
- [小学教育]二人以上股东有限责任公司章程参考样本
- [小学教育]2014届第一轮复习资料4.1,3美好生活的
- [小学教育]土方开挖、降水方案
- [小学教育]手绘儿童绘本《秋天的图画》(蜡笔)
- [小学教育]2002级硕士研究生卫生统计学考试试题
- [小学教育]环保装备重点发展目录
- [小学教育]金蝶K3合并报表培训教材
- [小学教育]岩浆岩试题及参考答案
- [小学教育]知之深爱之切学习心得
- [小学教育]第十二章 蛋白质的生物合成
- [小学教育]Chapter 2-3 Solid structure and basi
- [小学教育]市政道路雨季专项施工方案
- [小学教育]中国海洋大学2012-2013学年第二学期天
- [小学教育]教育心理学第3章-学习迁移
- 浅谈深化国企改革中加强党管企业
- 2006年中国病理生理学会学术活动安排
- 设计投标工作大纲
- 基于ARP的网络攻击与防御
- 2016届湖北省七市(州)教科研协作体高三
- Google_学术搜索及其检索技巧
- 2019-2020学年七年级地理下册6.3美洲教
- 城市道路可研报告
- 【名师指津】2012高考英语 写作基础技
- 6级知识点培训北京师范大学《幼儿智趣
- 注册会计师会计知识点:金融资产
- 新安装 500 kV 变压器介损分析与判断
- PS2模拟器PCSX2设置及使用教程.
- 医院药事管理与药剂科管理组织机构
- {PPT背景素材}丹巴的醉人美景,免费,一
- NAS网络存储应用解决方案
- 青海省西宁市六年级上学期数学期末考试
- 测量管理体系手册依据ISO10012:2003
- 洞子小学培养骨干教师工作计划
- 浅谈《牛津初中英语》的教材特点及教学




