ORACLE materialized view and oracle Materialized View

Source: Internet
Author: User
Tags oracle materialized view

ORACLE materialized view and oracle Materialized View

In the last few days, I have provided a View to the W System in the P project environment. Due to the complicated query logic and large data volume, the query speed is slow each time a view is queried, low Efficiency, and complaints from w system personnel. I thought about it. I want to change it to the materialized view. I used the materialized view. The waist is not sour, the legs are not painful, the query is fast, and the complaints are missing. Who knows who to use.

I really want to describe in detail the relevant content of the materialized view, which is too long, so here only records the operations I have done in this adjustment. Create the simplest materialized view without using quick refresh. Therefore, no materialized view logs are created here.

The statement for creating a materialized view is as follows (the query content is changed here due to data issues ):

Create materialized view MV_TableName build immediate -- refresh force immediately upon creation -- If REFRESH is enabled, REFRESH quickly, otherwise, completely refresh on demand -- refresh method start with sysdate -- first refresh time next sysdate + 1/12 -- refresh interval as select 1 id 'A' name FROM dual;

During execution in PLSQL, materialized views may fail to be created due to comments. Therefore, delete comments during creation.

 

To modify the refresh frequency in some cases, run the following command to modify the refresh interval:

ALTER MATERIALIZED VIEW MV_TableName       REFRESH FORCE        ON DEMAND        START WITH SYSDATE        NEXT SYSDATE+1/144;

 

Query the last refresh time of the Materialized View

SELECT last_refresh_date      FROM user_mviews     WHERE mview_name = 'MV_TABLENAME';

 

Manual refresh Materialized View

BEGIN       dbms_mview.refresh('MV_TABLENAME');    END;

 

To delete a materialized view, use the following statement:

DROP MATERIALIZED VIEW MV_TableName;

Oracle Materialized View

No. Your base table is an object table. Although the materialized view has the same functions as the actual table and improves the query speed, there is a fundamental difference. If you want to do this, you can create multiple materialized views. For the same table, or create A trigger on the created Materialized View A, you can generate logs by yourself, write a stored procedure and job for data synchronization. However, we recommend that you use the first one, which is simple.

How Does oracle manually refresh the materialized view?

Exec dbms_mvview.refresh ('mv _ name ');

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.