美文网首页
2018-07-31视图

2018-07-31视图

作者: 菩灵 | 来源:发表于2018-08-05 14:54 被阅读5次

视图:就是对select语句的一个封装,以v_开头,后面接as ,若修改用alter。

  • 对于复杂的查询,在多次使用后,维护是一件非常麻烦的事情
  • 解决:定义视图
  • 视图本质就是对查询的一个封装
  • 定义视图
create view stuscore as 
select students.*,scores.score from scores
inner join students on scores.stuid=students.id;

  • 视图的用途就是查询
select * from stuscore;

*用到select语句的时候直接用视图就行,方便使用和调用,

相关文章

网友评论

      本文标题:2018-07-31视图

      本文链接:https://www.haomeiwen.com/subject/lqvcvftx.html