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
百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说教育文库山东大学 数据库 实验四 复制表(2)在线全文阅读。
相关推荐: