抽取数据到另一个表中
--问题3.3将curse中报名人数大于20的课程编号、课程名称、学分和上课时间抽取到new——course表中
use [xk-zcx]
go
select couno,couname,credit,schooltime into new_course
from Course
where WillNum >20
go
use [xk-zcx]
go
select'课程编号'=couno,'课程名称'=couname,'credit','上课时间'=schooltime
into new_course
from Course
where willnum>20
go
--问题3.4将"01旅游管理"班级同学的学号、姓名和选修的课程编号、课程名称数据抽取到名为my—class的新表中。
use [xk-zcx]
go
select s.stuno,stuname,c.couno,couname into my_class
from Student s,Course c,StuCou sc,Class cl
where s.StuNo =sc.StuNo and
c.CouNo =sc.CouNo and
cl.ClassNo =s.ClassNo and
ClassName ='01旅游管理'
go
--问题3.5向department表中添加如下3行数据
use [xk-zcx]
go
insert Department
values ('11','数学系')
insert Department(DepartName,DepartNo )
values ('物理系','12')
insert Department(DepartNo ,DepartName )
values ('13','化学系')
go
select
from Department
go
--问题3.6向班级表中添加如下4行数据
use [xk-zcx]
go
insert into Class
select '20110001','03旅游管理','03'
union
select '20110002','03旅游管理','03'
union
select '20110003','02建筑管理','02'
union
select '20110004','02建筑管理','02'
go
select
from Class
go
delete from Student --删除学生表里
where StuName ='张埼文'
共同学习,写下你的评论
评论加载中...
作者其他优质文章