SQL 中视图和物化视图的区别
技术百科
WBOY
发布时间:2023-08-25
浏览: 次 任何数据库的主要组成部分是其表格,在为了使数据可访问性定制化的情况下,有视图的概念。换句话说,通过表格的视图,我们可以限制任何用户只能访问他应该访问的数据。现在基于视图的特点和特性,我们可以区分视图和物化视图。
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 SQL
Views 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 SQL
Materialized 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 SQL
The following table highlights the important differences between View
s and Materialized Views −
| Key | Views | Materialized 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)是非常不同的。当数据很少被访问,而表中的数据经常更新时,使用视图。相反,当数据需要频繁访问,而表中的数据不经常更新时,使用物化视图。
# 也有
# 都能
# 更快
# 情况下
# 与之
# 我们可以
# 组成部分
# 被称为
# 查询结果
# 上讲
相关栏目:
<?muma
$count = M('archives')->where(['typeid'=>$field['id']])->count();
?>
【
AI推广<?muma echo $count; ?>
】
<?muma
$count = M('archives')->where(['typeid'=>$field['id']])->count();
?>
【
SEO优化<?muma echo $count; ?>
】
<?muma
$count = M('archives')->where(['typeid'=>$field['id']])->count();
?>
【
技术百科<?muma echo $count; ?>
】
<?muma
$count = M('archives')->where(['typeid'=>$field['id']])->count();
?>
【
谷歌推广<?muma echo $count; ?>
】
<?muma
$count = M('archives')->where(['typeid'=>$field['id']])->count();
?>
【
百度推广<?muma echo $count; ?>
】
<?muma
$count = M('archives')->where(['typeid'=>$field['id']])->count();
?>
【
网络营销<?muma echo $count; ?>
】
<?muma
$count = M('archives')->where(['typeid'=>$field['id']])->count();
?>
【
案例网站<?muma echo $count; ?>
】
<?muma
$count = M('archives')->where(['typeid'=>$field['id']])->count();
?>
【
精选文章<?muma echo $count; ?>
】
相关推荐
- 如何理解Go指针和内存分配关系_Go Pointe
- php报错怎么查看_定位PHP致命错误与警告的方法
- Win11怎么开启剪贴板历史记录_Windows1
- Win11怎么设置单手模式_Win11触控键盘布局
- Mac的访达(Finder)怎么用_Mac文件管理
- 如何使用Golang benchmark测量函数延
- MySQL 中使用 IF 和 CASE 实现查询字
- php485在php5.6下能用吗_php485旧
- Win10怎样安装Excel数据分析工具_Win1
- php和redis连接超时怎么办_phpredis
- Win11时间怎么同步到原子钟 Win11高精度时
- php打包exe后无法读取环境变量_变量配置方法【
- Win10系统字体模糊怎么办_Windows10高
- Windows10怎么查看硬件信息_Windows
- Win10如何备份注册表_Win10注册表备份步骤
- LINUX下如何配置VLAN虚拟局域网_在LINU
- c# F# 的 MailboxProcessor
- Mac如何解压zip和rar文件?(推荐免费工具)
- 如何使用Golang处理静态文件缓存_提高页面加载
- c++如何使用std::bind绑定函数参数_c+
- Windows怎样关闭锁屏广告_Windows关闭
- Win11怎么设置组合键快捷方式_Windows1
- VSC怎样在Linux运行PHP_Ubuntu系统
- c++23 std::expected怎么用 c+
- PythonFastAPI项目实战教程_API接口
- 如何在 PHP 单元测试中正确模拟带方法的图像处理
- 如何使用Golang实现容器自动化运维_Golan
- Windows10如何查看蓝屏日志_Win10使用
- Win11怎么关闭搜索历史 Win11清除搜索框最
- Win11怎么关闭透明效果_Windows11个性
- Django 密码修改后会话失效的解决方案
- php文件怎么变mp4保存_php输出视频流保存为
- Win11怎样激活系统密钥_Win11系统密钥激活
- 如何在Golang中使用time处理时间_Gola
- Win11时间不对怎么同步_Win11自动校准互联
- Windows10如何重置此电脑_Windows1
- Win11用户账户控制怎么关_Win11关闭UAC
- PHP主流架构怎么集成Redis缓存_配置步骤【方
- Mac怎么设置登录项_Mac管理开机自启动程序【教
- 如何在Golang中写入JSON文件_保存结构体数
- Win11怎么更改默认打开方式_Win11关联文件
- c++中如何进行二进制文件读写_c++ read与
- Win10怎么卸载迅雷_Win10彻底卸载迅雷方法
- Win11开机Logo怎么换_Win11自定义启动
- LINUX如何查看文件类型_Linux中file命
- Win11关机界面怎么改_Win11自定义关机画面
- 本地php环境打开php文件直接下载_浏览器解析p
- Win11怎么格式化U盘_Win11系统U盘格式化
- Win11如何设置系统声音_Win11系统声音调整
- Win10怎么限制单程序CPU占用上限_Win10

QQ客服