数据库技术
视图
-
定义视图 : sql使用create view语句定义视图,其一般格式为:
-
建立咖啡类视图:
create view coffe
as
select goodsno,goodsname,inprice,saleprice,producttime from goods g join category c on g.categoryno=c.categoryno where categoryname=’咖啡’ -
建立mis专业学生的视图,并要求通过视图完成修改与插入操作时视图仍只有mis专业学生:
create view mis_student
as
select *from student
where major=‘mis’ with check option -
建立购买了咖啡类商品的学生视图
create view buy_coffee
as
selectfrom student
where exists
(selectfrom salebill s join coffee c on c.goodsno=s.goodsno where s.sno=student.sno)