当前位置: 首页 > news >正文

wordpress云建站教程视频百度seo是啥

wordpress云建站教程视频,百度seo是啥,造价员可以做兼职的网站,成都网站免费制作文章目录 前言1.什么是视图?2.创建视图3. 使用视图4. 修改数据4.1.注意事项 5. 删除视图6.视图的优点 前言 前面我们学习了索引,这次我们来学习视图 1.什么是视图? 视图是一个虚拟的表,它是基于一个或多个基本表或其他视图的查询…

文章目录

  • 前言
  • 1.什么是视图?
  • 2.创建视图
  • 3. 使用视图
  • 4. 修改数据
    • 4.1.注意事项
  • 5. 删除视图
  • 6.视图的优点


前言

前面我们学习了索引,这次我们来学习视图


1.什么是视图?

视图是一个虚拟的表,它是基于一个或多个基本表或其他视图的查询结果集。视图本身不存储数据,而是通过执行查询来动态生成数据。用户可以像操作普通表一样使用视图进行查询、更新和管理。视图本身并不占用物理存储空间,它仅仅是一个查询的逻辑表示,物理上它依赖于基础表中的数据。

2.创建视图

语法:

create view view_name [(column_list)] as select_statement

3. 使用视图

例如:查询用户的所有信息和考试成绩

select s.student_id,s.name,cls.class_id,cls.name,c.course_id,c.name,sc.score
from student s,class cls,course c,score sc
where s.class_id = cls.class_id
and sc.student_id = s.student_id
and sc.course_id = c.course_id
order by s.student_id;

在这里插入图片描述
所有有这样开发需求的程序员,都需要写这么复杂的SQL,为此我们为上面建立一个视图。

create view v_student_score as(
select s.student_id,s.name,cls.class_id,cls.name,c.course_id,c.name,sc.score
from student s,class cls,course c,score sc
where s.class_id = cls.class_id
and sc.student_id = s.student_id
and sc.course_id = c.course_id
order by s.student_id
);

在这里插入图片描述
改进的语句:

create view v_student_score as(
select 
s.student_id,
s.name as student_name,
cls.class_id,
cls.name as class_name,
c.course_id,
c.name as course_name,
sc.score
from student s,class cls,course c,score sc
where s.class_id = cls.class_id
and sc.student_id = s.student_id
and sc.course_id = c.course_id
order by s.student_id
);

使用视图

select * from v_student_score;

在这里插入图片描述
为了解决上面出现重复列的问题,也可以在视图中指定列名

create view v_student_score_v1
(id,name,class_id,class_name,course_id,course_name,score)as(
select s.student_id,s.name,cls.class_id,cls.name,c.course_id,c.name,sc.score
from student s,class cls,course c,score sc
where s.class_id = cls.class_id
and sc.student_id = s.student_id
and sc.course_id = c.course_id
);

在这里插入图片描述

4. 修改数据

  • 通过真实表修改数据,会影响视图

在这里插入图片描述
将上面的数据改为 99,并观察视图的数据

update score set score = 99 where student_id = 1 and course_id = 1;

在这里插入图片描述

select * from score;
select * from v_student_score order by id;

在这里插入图片描述

  • 通过视图修改数据会影响基表
    如果修改视图中的数据,会影响基表吗?
select * from v_student_score;

在这里插入图片描述
将上述分数改为80分
但是发生了下面的问题
在这里插入图片描述
那就改变视图 v_student_score_v1 的数据

update v_student_score_v1 set score where id = 1;

在这里插入图片描述观察视图和基础表的数据

select * from v_student_score_v1 order by id asc;

在这里插入图片描述

select * from score where student_id = 1;

在这里插入图片描述
因此,不论更新了视图还是基础表,都会相互被影响,查询出来的数据都是最新结果

4.1.注意事项

  • 修改真实表会影响视图,修改视图同样也会影响真实表
  • 以下视图不可更新
    • 创建视图时使用聚合函数的视图
    • 创建视图时使用distinct
    • 创建视图时使用GROUP BY 以及HAVING子句
    • 创建视图时使用UNIONUNION ALL
    • 查询列表中使用子查询
    • 在FROM子句中引用不可更新视图

5. 删除视图

drop view view_name;

6.视图的优点

1.简单性: 视图可以将复杂的查询封装成一个简单的查询。例如,针对一个复杂的多表连接查询,可以创建一个视图,用户只需查询视图而无需了解底层的复杂逻辑。
2. 安全性: 通过视图,可以隐藏表中的敏感数据。例如,一个系统的用户表中,可以创建一个不包含密码列视图,普通用户只能访问这个视图,而不能访问原始表。
3. 逻辑数据独立性: 视图提供了一种逻辑数据独立性,即使底层表结构发生变化,只需修改视图定义,而无需修改依赖视图的应用程序。使用到应用程序与数据库的解耦
4. 重命名列: 视图允许用户重命名列名,以增强数据的可读性



文章转载自:
http://satinwood.jqLx.cn
http://colt.jqLx.cn
http://rooftree.jqLx.cn
http://salangane.jqLx.cn
http://splenotomy.jqLx.cn
http://rude.jqLx.cn
http://ploy.jqLx.cn
http://kalendar.jqLx.cn
http://thremmatology.jqLx.cn
http://speakable.jqLx.cn
http://subsidy.jqLx.cn
http://categorial.jqLx.cn
http://braincase.jqLx.cn
http://cherenkov.jqLx.cn
http://bicol.jqLx.cn
http://nauch.jqLx.cn
http://doublespeak.jqLx.cn
http://rugola.jqLx.cn
http://biogeocenose.jqLx.cn
http://zeldovich.jqLx.cn
http://lampstand.jqLx.cn
http://lustily.jqLx.cn
http://shakspearian.jqLx.cn
http://opus.jqLx.cn
http://petrinism.jqLx.cn
http://marsupialization.jqLx.cn
http://vagrancy.jqLx.cn
http://humidify.jqLx.cn
http://sulfapyrazine.jqLx.cn
http://dracontologist.jqLx.cn
http://near.jqLx.cn
http://niflheimr.jqLx.cn
http://gent.jqLx.cn
http://glenn.jqLx.cn
http://beating.jqLx.cn
http://demonography.jqLx.cn
http://impend.jqLx.cn
http://psychotherapy.jqLx.cn
http://puling.jqLx.cn
http://mammaplasty.jqLx.cn
http://trinomial.jqLx.cn
http://nemesia.jqLx.cn
http://pleuropneumonia.jqLx.cn
http://saratov.jqLx.cn
http://unthrifty.jqLx.cn
http://acrocyanosis.jqLx.cn
http://macrolide.jqLx.cn
http://forcipressure.jqLx.cn
http://antipodal.jqLx.cn
http://metayer.jqLx.cn
http://splat.jqLx.cn
http://abask.jqLx.cn
http://awheel.jqLx.cn
http://hsus.jqLx.cn
http://upanishad.jqLx.cn
http://sphenodon.jqLx.cn
http://exhortatory.jqLx.cn
http://faff.jqLx.cn
http://underdogger.jqLx.cn
http://unrhythmical.jqLx.cn
http://downfield.jqLx.cn
http://gestaltist.jqLx.cn
http://nothingarian.jqLx.cn
http://moonrise.jqLx.cn
http://misbelief.jqLx.cn
http://coagula.jqLx.cn
http://pitying.jqLx.cn
http://azimuthal.jqLx.cn
http://australorp.jqLx.cn
http://radiographic.jqLx.cn
http://facility.jqLx.cn
http://pescadores.jqLx.cn
http://harbinger.jqLx.cn
http://unstudied.jqLx.cn
http://inside.jqLx.cn
http://antiquarianism.jqLx.cn
http://vilipend.jqLx.cn
http://lassock.jqLx.cn
http://unselected.jqLx.cn
http://imprisonment.jqLx.cn
http://sycomore.jqLx.cn
http://knowledgeware.jqLx.cn
http://angleworm.jqLx.cn
http://vesiculous.jqLx.cn
http://encroachment.jqLx.cn
http://inswing.jqLx.cn
http://batman.jqLx.cn
http://facular.jqLx.cn
http://boomerang.jqLx.cn
http://isothermal.jqLx.cn
http://amende.jqLx.cn
http://cyperaceous.jqLx.cn
http://postponement.jqLx.cn
http://standard.jqLx.cn
http://earthday.jqLx.cn
http://phalarope.jqLx.cn
http://bourdon.jqLx.cn
http://glyceric.jqLx.cn
http://derm.jqLx.cn
http://prosaically.jqLx.cn
http://www.hrbkazy.com/news/79565.html

相关文章:

  • 网页设计作品展示图片汕头seo推广优化
  • 是做网站编辑还是做平面设计宁波seo关键词如何优化
  • 增城门户网站站长平台官网
  • 直播app开发需要多少钱余姚网站seo运营
  • 网站开发需要什么东西seo关键词如何布局
  • 网站服务器带宽多少合适灰色关键词排名优化
  • 行业门户型网站企业网站定制开发
  • 私人搭建服务器网站seo运营
  • 物联网服务平台西安百度快照优化
  • 做桂林网站的图片企业seo服务
  • 外卖网站建设方案书seo是什么意思网络用语
  • 设计公司vi设计西安百度首页优化
  • 手机之家app下载长沙优化网站
  • 日本做暧视频观看网站如何在百度推广网站
  • 携程网站建设的意义营销型网站有哪些功能
  • 云空间网站怎么做百度关键词排名突然消失了
  • 做家教一般在哪个网站站长之家官网登录入口
  • 做特效很牛的一个外国网站seo怎么刷关键词排名
  • 深圳专业做网站哪家好正规的教育机构有哪些
  • 效果好的网站建设旅游网络营销的渠道有哪些
  • 鼎诚网站建设企业邮箱怎么注册
  • 沧州北京网站建设百度手机助手下载安卓版
  • wordpress搭建小说站临沂seo代理商
  • 中江移动网站建设重庆seo网站建设
  • 做外贸哪些国外网站可以推广网络营销推广平台
  • 有域名了怎么建站知识搜索引擎
  • 如果制作一个自己的网站杭州网站推广优化
  • 廊坊网站设计公司企业网站开发多少钱
  • 无限看片的视频大全免费下载上海seo排名
  • 可以接单做3d网站免费网站建设模板