Oracle materialized view, materialized view log, incremental refresh synchronization remote database, oracle materialized

Source: Internet
Author: User

Oracle materialized view, materialized view log, incremental refresh synchronization remote database, oracle materialized

1. Create DBLINK

 -- Drop existing database link 
drop public database link LQPVPUB;
-- Create database link
CREATE DATABASE LINK LQPVPUB 6 CONNECT TO "INTEPDM" identified by "password" 8 using "LQPVPUB"

2. Create materialized view logs (remote host operations)

 CREATE MATERIALIZED VIEW LOG ON dm_basicmodel  
WITH PRIMARY KEY
INCLUDING NEW VALUES;

3. Create a Materialized View

Create materialized view mv_model -- create materialized view build immediate -- create refresh fast with primary key after the VIEW is compiled -- incrementally REFRESH (FAST, incremental) based on the primary key of the master table) on demand -- when the user needs it, the user refresh enable query rewrite -- can read and write
SELECT bm_id, bm_partid, bm_code from dm_basicmodel @ LQPVPUB t -- query statement

4. Delete materialized views and logs

Logs and materialized views should be deleted separately

 DROP MATERIALIZED VIEW LOG ON GG_ZLX_ZHU@TOCPEES;   

 DROP MATERIALIZED VIEW GG_ZLX_ZHU;  

5. materialized view update

CREATE OR REPLACE PROCDURE P_MVIEW_REFRESH AS  BEGIN      DBMS_MVIEW.REFRESH('GG_ZLX_ZHU,GG_ZLX_FU','ff');  END P_MVIEW_REFRESH;  

Note:

5.1 if you need to refresh multiple materialized views at the same time, you must use commas to connect the names of materialized views and specify the refresh method for each view.

(F. incremental refresh, c. Completely refresh ,? , Force refresh ).

5.2 After the log and materialized view are created on the current day, delete the log and create a new materialized view. Otherwise, the log cannot be refreshed incrementally.

5.3 because the materialized views written above are updated based on the primary key, the primary table must have a primary key.

6. query the refresh status

For a Complete refresh (Complete), the refresh duration is recorded in the FULLREFRESHTIM column of DBA_MVIEW_ANALYSIS.

The time that can be quickly refreshed is recorded in the INCREFRESHTIM column.

The two values are measured in seconds.
SELECT mview_name, last_refresh_date, fullrefreshtim, increfreshtim
FROM dba_mview_analysis
WHERE owner='JOHN';

 

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.