"Oracle" materialized view

Source: Internet
Author: User

Materialized view: A special view with physical storage, just like a Table object. Materialized views and tables can be queried directly. It is one of the effective methods to optimize the query performance and improve the efficiency of the system, which is the function of the distributed query through the read-write separation mechanism.

Create:

Create View  [fast|complete|force][on[Commit|demand]|  with next  (next_time)][enable query rewrite  ]as {Create a query statement for materialized views}

To create a materialized view:

--The materialized view log needs to be created using the fast Refresh method:SCOTT>CreateMaterializedView Log  onEMP;--To create a materialized view:SCOTT>CreateMaterializedViewEmp_mview2Build Immediate3Refresh Fast on Commit  4Enable query rewrite5   as  6  Select *  fromEmp

To delete a materialized view:

SCOTT>dropview  Emp_mview; SCOTT>dropviewlog on EMP;

Creating materialized views requires create materialized View permissions:

SYS>Grantcreateview to Scott;

Query rewriting: When querying the base table of a materialized view, Oracle automatically determines whether the results can be obtained by querying materialized views. The optimizer automatically calculates whether materialized views can meet query requirements and improve performance. If requirements are met and performance is improved, the optimizer overrides the query and uses materialized views to obtain the results. Query rewriting is transparent to the user.

To turn on the query rewriting feature, set the query_rewrite_enabled parameter to true:

SYS>show parameter query_rewrite_enabledname                                 TYPE        VALUE--------------- --------------------------------------------------------------query_rewrite_enabled                string      TRUE

How the materialized view is refreshed:

    • On commit: The materialized view is refreshed immediately after the base table updates the data submission.
    • On demand: Manually call the Dbms_mview.refresh process to refresh the materialized view.

Complete: Full refresh to re-execute the SQL statement that created the materialized view.

Fast: Incremental refresh, updating only the changed data, to create a materialized view log.

Force: Use Fast update first, or complete if it fails.

Never: not refreshed.

"Oracle" materialized view

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.