SQL 中視圖和物化視圖的區別

WBOY
發布: 2023-08-25 16:49:23
轉載
1362 人瀏覽過

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

任何資料庫的主要組成部分是其表格,在為了使資料可訪問性定制化的情況下,有視圖的概念。換句話說,透過表格的視圖,我們可以限制任何使用者只能存取他應該存取的資料。現在基於視圖的特性和特性,我們可以區分出視圖和物化視圖

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 betwelave look into the basics of views and materialized view betweian formifference .

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 orform. 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 Views and Materialized Views −

由於Views沒有與之相關的儲存成本,因此它們也沒有與之相關的更新成本。 Materialized Views有與之相關的儲存成本,因此也有與之相關的更新成本。 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。
#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 ifd inv.
#成本效益
Design
使用情況
結論

在SQL中,視圖(Views)和物化視圖(Materialized Views)是非常不同的。當資料很少被訪問,而表中的資料經常更新時,使用視圖。相反,當資料需要頻繁訪問,而表中的資料不經常更新時,使用物化視圖。

以上是SQL 中視圖和物化視圖的區別的詳細內容。更多資訊請關注PHP中文網其他相關文章!

來源:tutorialspoint.com
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!