Materialized View in Oracle - Concepts and Architecture
List all of MV inoracle:
select owner, query, query_len
from dba_mviews
See content of aMV:
select *from dba_mviewswhere owner='CNTL_DATA'
A materialized viewis a database object that contains the results of a query. For example, it maybe a local copy of data located remotely, or may be a subset of the rows and/orcolumns of a table or join result, or may be a summary based on aggregations ofa table’s data. Materialized views, which store data based on remote tables,are also known as snapshots. A snapshot can be redefined as a materializedview.
In any database managementsystem for following the relational model, a view is a virtual tablerepresenting the result of a database query. Whenever a query or an updateaddresses an ordinary view’s virtual table, the DBMS converts these intoqueries or updates against the underlying base tables. A materialized viewtakes a different approach in which the query result is cached as a concretetable that may be updated from the original base tables from time to time. Thisenables much more efficient access, at the cost of some data being potentiallyout-of-date. It is most useful in data warehousing scenarios, where frequentqueries of the actual base tables can be extremely expensive.
In addition, becausethe materialized view is manifested as a real table, anything that can be doneto a real table can be done to it, most importantly building indexes on anycolumn, enabling drastic speedups in query time. In a normal view, it’s typicallyonly possible to exploit indexes on columns that come directly from (or have amapping to) indexed columns in the base tables; often this functionality is notoffered at all. Materialized views were implemented first by the OracleDatabase: the Query rewrite feature was added from version 8i. They are alsosupported in Sybase SQL Anywhere. In IBMDB2, they are called “materialized query tables”; MS SQL called “indexed views”.
Example syntax tocreate a materialized view in oracle:
CREATE MATERIALIZED VIEW MV_MY_VIEW
REFRESH FAST START WITH SYSDATE
NEXT SYSDATE +
AS SELECT * FROM <table_name>;
Oracle usesmaterialized views to replicate data to non-master sites in a replication environmentand to cache expensive queries in a data warehouse environment.
A materialized viewis a replica of a target master from a single point in time. The master can beeither a master table at a master site or a master materialized view at amaterialized view site. Whereas in multimaster replication tables arecontinuously updated by other master sites, materialized views are update fromone or more masters through individual batch updates, known as a refreshes,from a single master site or master materialized view site.
MaterializedView Connected to a Single Master Site
When a materializedview is fast refreshed, Oracle must examine all of the changes to the mastertable or master materialized view since the last refresh to see if any apply tothe materialized view. Therefore, if any changes were made to the master sincethe last refresh, then a materialized view refresh takes some time to apply thechanges to the materialized view. If, however, no changes at all were made tothe master since the last refresh of a materialized view, then the materializedview refresh should be very quick.
You can usematerialized views to achieve one or more of the following goals:
- Ease Network Loads
If one of your goals is to reduce network loads, then you can usematerialized views to distribute your corporate database to regional sites.Instead of the entire company accessing a single database server, user load isdistributed across multiple database servers. Through the use of multitiermaterialized views, you can create materialized views based on othermaterialized views, which enables you to distribute user load to an evengreater extent because clients can access materialized view sites instead ofmaster sites. To decrease the amount of data that is replicated, a materializedview can be a subset of a master table or master materialized view.Whilemultimaster replication also distributes a corporate database among multiplesites, the networking requirements for multimaster replication are greater thanthose for replicating with materialized views because of the transaction bytransaction nature of multimaster replication. Further, the ability ofmultimaster replication to provide real-time or near real-time replication mayresult in greater network traffic, and might require a dedicated network link.Materializedviews are updated through an efficient batch process from a single master siteor master materialized view site. They have lower network requirements anddependencies than multimaster replication because of the point in time natureof materialized view replication. Whereas multimaster replication requiresconstant communication over the network, materialized view replication requiresonly periodic refreshes.In addition to not requiring a dedicated networkconnection, replicating data with materialized views increases dataavailability by providing local access to the target data. These benefits,combined with mass deployment and data subsetting (both of which also reducenetwork loads), greatly enhance the performance and reliability of yourreplicated database.
- Create a Mass Deployment Environment
Deployment templates allow you to pre-create amaterialized view environment locally. You can then use deployment templates toquickly and easily deploy materialized view environments to support sales forceautomation and other mass deployment environments. Parameters allow you tocreate custom data sets for individual users without changing the deploymenttemplate. This technology enables you to roll out a database infrastructure tohundreds or thousands of users.
- Enable Data Subsetting
Materialized views allow you to replicate data basedon column- and row-level subsetting, while multimaster replication requiresreplication of the entire table. Data subsetting enables you to replicateinformation that pertains only to a particular site. For example, if you have aregional sales office, then you might replicate only the data that is needed inthat region, thereby cutting down on unnecessary network traffic.
- Enable Disconnected Computing
Materialized views do not require a dedicatednetwork connection. Though you have the option of automating the refreshprocess by scheduling a job, you can manually refresh your materialized viewon-demand, which is an ideal solution for sales applications running on alaptop. For example, a developer can integrate the replication management APIfor refresh on-demand into the sales application. When the salesperson hascompleted the day's orders, the salesperson simply dials up the network anduses the integrated mechanism to refresh the database, thus transferring theorders to the main office.
A materialized viewcan be either read-only, updatable, or writeable. Users cannot perform datamanipulation language (DML) statements on read-only materialized views, butthey can perform DML on updatable and writeable materialized views.
Read-OnlyMaterialized Views
You can make amaterialized view read-only during creation by omitting the FOR UPDATE clauseor disabling the equivalent option in the Replication Management tool.Read-only materialized views use many of the same mechanisms as updatablematerialized views, except that they do not need to belong to a materializedview group.
In addition, usingread-only materialized views eliminates the possibility of a materialized viewintroducing data conflicts at the master site or master materialized view site,although this convenience means that updates cannot be made at the remotematerialized view site. The following is an example of a read-only materializedview:
CREATE MATERIALIZEDVIEW hr.employees AS
SELECT * FROM hr.employees@orc1.world;
UpdatableMaterialized Views
You can make amaterialized view updatable during creation by including the FOR UPDATE clauseor enabling the equivalent option in the Replication Management tool. Forchanges made to an updatable materialized view to be pushed back to the masterduring refresh, the updatable materialized view must belong to a materializedview group.Updatable materialized views enable you to decrease the load onmaster sites because users can make changes to the data at the materializedview site. The following is an example of an updatable materialized view:
CREATE MATERIALIZEDVIEW hr.departments FOR UPDATE AS
SELECT * FROM hr.departments@orc1.world;
The followingstatement creates a materialized view group:
BEGIN
DBMS_REPCAT.CREATE_MVIEW_REPGROUP (
gname => 'hr_repg',
master => 'orc1.world',
propagation_mode => 'ASYNCHRONOUS');
END;
/
The followingstatement adds the hr.departments materialized view to the materialized viewgroup, making the materialized view updatable:
BEGIN
DBMS_REPCAT.CREATE_MVIEW_REPOBJECT (
gname => 'hr_repg',
sname => 'hr',
oname => 'departments',
type => 'SNAPSHOT',
min_communication => TRUE);
END;
/
WriteableMaterialized Views
A writeablematerialized view is one that is created using the FOR UPDATE clause but is notpart of a materialized view group. Users can perform DML operations on awriteable materialized view, but if you refresh the materialized view, thenthese changes are not pushed back to the master and the changes are lost in thematerialized view itself. Writeable materialized views are typically allowedwherever fast-refreshable read-only materialized views are allowed.
Materialized View in Oracle - Concepts and Architecture的更多相关文章
- oracle view and MATERIALIZED VIEW
View http://blog.csdn.net/tianlesoftware/article/details/5530618 MATERIALIZED VIEW http://blog.csdn. ...
- Oracle数据库零散知识07 -- Materialized view(转)
物化视图是一种特殊的物理表,“物化”(Materialized)视图是相对普通视图而言的.普通视图是虚拟表,应用的局限性大,任何对视图的查询,Oracle都实际上转换为视图SQL语句的查询.这样对整体 ...
- MySQL 5.6 Reference Manual-14.2 InnoDB Concepts and Architecture
14.2 InnoDB Concepts and Architecture 14.2.1 MySQL and the ACID Model 14.2.2 InnoDB Multi-Versioning ...
- [terry笔记]物化视图 materialized view基础学习
一.物化视图定义摘录: 物化视图是包括一个查询结果的数据库对像(由系统实现定期刷新数据),物化视图不是在使用时才读取,而是预先计算并保存表连接或聚集等耗时较多的操作结果,这样在查询时大大提高了 ...
- What is the difference between Views and Materialized Views in Oracle?
aterialized views are disk based and update periodically base upon the query definition. Views are v ...
- MATERIALIZED VIEW
Oracle的实体化视图提供了强大的功能,可以用在不同的环境中,实体化视图和表一样可以直接进行查询.实体化视图可以基于分区表,实体化视图本身也可以分区. 主要用于预先计算并保存表连接或聚集等耗时较多的 ...
- Advanced Replication同步复制实验(基于Trigger&基于Materialized View)
1. 高级复制和流复制介绍 1.1 高级复制(Advanced Replication) 高级复制也称为对称复制,分为多主体站点复制(Multiple Master Rplication).物化视图站 ...
- 物化视图(materialized view) 实现数据迁移、数据定时同步
近日公司有一个9i 的Oracle数据库,运行效率低下.想要将其升级到11G. 但是升级之前 要将数据进行同步,好在表不是很多.只有三张表.业务压力也不大,就想到了使用物 化视图的方式将数据同步过来. ...
- ORA-12052: cannot fast refresh materialized view
SQL> execute dbms_mview.refresh ('TX_FAIL_LOG_DAY_MV', 'f'); BEGIN DBMS_MVIEW.REFRESH ('TX_FAIL_L ...
随机推荐
- HTML5 标准属性 NEW:HTML 5 中新的标准属性。 注释:HTML 4.01 不再支持 accesskey 属性:
属性 值 描述 accesskey character 规定访问元素的键盘快捷键 class classname 规定元素的类名(用于规定样式表中的类). contenteditable true f ...
- poj 1150 The Last Non-zero Digit
/** 大意: 求A(n,m)的结果中从左到右第一个非零数 思路: 0是由2*5的得到的,所以将n!中的2,5约掉可得(2的数目比5多,最后再考虑进去即可) 那n!中2 的个数怎么求呢? int ge ...
- django最佳实践
导入的时候使用绝对导入或者清晰的相对导入 相对导入用法: from __future__ import absolute_import from .models import what_u_need ...
- Android外部存储 - 官方文档解读
预备知识:External Storage Technical Information 摘要: "The WRITE_EXTERNAL_STORAGE permission must onl ...
- Part Acquisition(spfa输出路径)
Part Acquisition Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 4080 Accepted: 1742 ...
- hadoop、spark/storm等大数据相关视频资料汇总下载
小弟不才,工作中也用到了大数据的相关东西.一開始接触的时候,是通过买来的教学视频入的门.这两天整理了一下自己的视频资料.供各位进行下载. 文档截图:
- 浅谈独立使用NDK编译库文件(Android)
阅读前准备 这是一篇相对入门的文章.文中会涉及到少许NDK的知识,但个人认为对初学者来说都相对比较实用,因为都是在平时项目中遇到的(目前自己也是初学者).一些其他高深的技术不再本文探讨范围之内(因为我 ...
- 基于mini2440的IIC读写(裸机)
mini2440开发板提供的测试代码过于复杂,让人很难理解,而且有些错误,如GPE14-15不能设置上拉电阻,可是代码里却设置了,虽然无关紧要.为了方便学习,我在闲暇之时我研究了一下.IIC的原理是比 ...
- Android显示GIF动画完整示例(一)
MainActivity如下: package cc.testgif; import com.ant.liao.GifView; import com.ant.liao.GifView.GifImag ...
- window下如何搭建linux环境
1.使用虚拟机 使用VMware虚拟机,下载linux内核系统,加载运行. 2.cygwin 安装cygwin,设置环境变量. 第二种方法还是比较简便的.优先考虑.