山东大学 数据库 实验四 复制表(2)

2020-11-29 00:55

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


山东大学 数据库 实验四 复制表(2).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:产品说明书编写规范

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: