Materialized View and task scheduling data synchronization

Source: Internet
Author: User


Materialized View and task scheduling data synchronization 1. materialized view (materialized view) www.2cto.com create materialized view TEST_MATERIAL_VIEW (materialized view name) refresh force on demandstart WITHTO_DATE ('02-11-2012 14:24:59 ', 'dd-MM-YYYY HH24: MI: SS ') (Start Time) next sysdate + 1/1440 (Execution interval) asselect id, NAME, addr from testtest; (Materialized View query statement) www.2cto.com Remarks: This example indicates, query related field data in the TESTTEST table every minute and display it in the materialized view TEST_MATERIAL_VIEW. That is to say, the data update frequency in TEST_MATERIAL_VIEW is 1 minute and 2. stored PROCEDURE + JOB [1] procedurecreate or replace procedure P_HANDLEB2CCOMMAND (stored PROCEDURE name) isbeginmerge into TEST_PRO W (table to be updated) using testtest ww (associated data or table) ON (W. ID = WW. ID) (Association condition) when matched then update (if conditions are met) set w. NAME = WW. NAME, W. ADDR = WW. addr where w. ID = WW. idwhen not matched then insert (if the condition is NOT met, INSERT) VALUES (WW. ID, WW. NAME, WW. ADDR); END; [2] jobbegin sys. DBMS_JOB.SUBMIT (JOB =>: JOB, WHAT => 'P _ HANDLEB2CCOMMAND; ', NEXT_DATE => TO_DATE ('02-11-2012 14:33:24', 'dd-MM-YYYY HH24: MI: SS '), INTERVAL => 'sysdate + 1/1440'); COMMIT; END; Note: This example shows that the task runs the stored procedure every minute, determine whether the table TEST_PRO to be updated has the corresponding data based on the ID. If yes, update the table as needed. If no table exists, insert the data to ensure that the table TEST_PRO is incremental data.

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.