您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息
免费发信息

SQL 中视图和物化视图的区别

2024/4/17 12:47:45发布6次查看
任何数据库的主要组成部分是其表格,在为了使数据可访问性定制化的情况下,有视图的概念。换句话说,通过表格的视图,我们可以限制任何用户只能访问他应该访问的数据。现在基于视图的特点和特性,我们可以区分视图和物化视图。
in this article, we will discuss the important differences between views and materialized views in sql. but before, let’s have look into the basics of views and materialized view individually for better understanding of the differences between them.
views in sqlviews are the logical and virtual copy of a table that is created by executing a ‘select query’ statement. the views are not stored anywhere on the disk. thus, every time, a query has to be executed when certain data is required. but, the query expression is stored on the disk.
视图没有与之相关的存储/更新成本。视图是根据特定的架构设计的,这意味着有一个sql标准来定义视图。视图在数据需要被不经常访问,但数据经常更新时使用。
materialized views in sqlmaterialized views are the views whose contents are computed and stored. materialized views are also a logical virtual table, but in this case the result of the query is stored in the table or the disk. the performance of the materialized views is better than normal views. this is because the data is stored on the disk.
有时,物化视图也被称为“索引视图”,因为查询后创建的表被索引,可以更快、更高效地访问。当数据需要频繁访问且表中的数据不经常更新时,会使用物化视图。
difference between views and materialized views in sqlthe following table highlights the important differences between views and materialized views −
keyviewsmaterialized views
definition 从技术上讲,表的视图是通过“select查询”创建的表的逻辑虚拟副本,但结果不会存储在磁盘上。whenever we need the data, we need to fire the query. so, the user always gets the updated or latest data from the original tables.
materialized views(物化视图)也是数据的逻辑虚拟副本,由“select查询”驱动,但查询结果将存储在表格或磁盘中。
storage in views the resulting tuples of the query expression is not get storing on the disk only the query expression is stored on the disk. 在物化视图的情况下,查询表达式和查询结果的元组都存储在磁盘上。
查询执行 查询表达式存储在磁盘上,而不是其结果,因此每次用户尝试从中提取数据时,查询表达式都会被执行,以便用户每次都能获得最新的更新值。 the result of the query gets stored on the disk and hence the query expression does not get executed every time when user try to fetch the data so that user will not get the latest updated value if it get changed in database.
成本效益 由于views没有与之相关的存储成本,因此它们也没有与之相关的更新成本。 materialized views有与之相关的存储成本,因此也有与之相关的更新成本。
design views in sql are designed with a fixed architecture approach due to which there is an sql standard of defining a view. materialized views in sql are designed with a generic architecture approach, so there is no sql standard for defining it, and its functionality is provided by some databases systems as an extension.
使用情况 views are generally used when data is to be accessed infrequently and data in table get updated on frequent basis. 当数据需要频繁访问且表中的数据不经常更新时,使用materialized views。
结论在sql中,视图(views)和物化视图(materialized views)是非常不同的。当数据很少被访问,而表中的数据经常更新时,使用视图。相反,当数据需要频繁访问,而表中的数据不经常更新时,使用物化视图。
以上就是sql 中视图和物化视图的区别的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录