1,查看刷新组信息:
SQL> select rowner,rname,refgroup,job,next_date,interval,broken from dba_refresh;
ROWNER RNAME REFGROUP JOB NEXT_DATE INTERVAL B
---------- ------------- ---------- ---------- ------------------- -------------------- -
MVADMIN REP_REFRESH 1 41 2012-09-03 10:36:21 sysdate+1/(24*12) N
2,查看刷新组内包含哪些要刷新的物化视图
SQL> select owner,name,rowner,rname,refgroup,job,next_date from dba_refresh_children;
OWNER NAME ROWNER RNAME REFGROUP JOB NEXT_DATE
-------- -------- ---------- ------------- ---------- ---------- -------------------
TESTER T1MV MVADMIN REP_REFRESH 1 41 2012-09-03 10:36:21
TESTER T2MV MVADMIN REP_REFRESH 1 41 2012-09-03 10:36:21
3,查看都有哪些物化视图
SQL> select owner,mview_name,MASTER_LINK,REFRESH_METHOD,LAST_REFRESH_DATE from all_mviews;
OWNER MVIEW_NAME MASTER_LIN REFRESH_ LAST_REFRESH_DATE
-------- --------------- ---------- -------- -------------------
TESTER T1MV @NEWDB.MDU FAST 2012-09-03 10:36:01
TESTER T2MV @NEWDB.MDU FORCE 2012-09-03 10:36:01
4,查看job的信息
SQL> select job,log_user,last_date,next_date,broken,interval,failures,what from dba_jobs where job=41;
JOB LOG_USER LAST_DATE NEXT_DATE B INTERVAL FAILURES WHAT
---------- ---------- ------------------- ------------------- - -------------------- ---------- ------------------------------
41 MVADMIN 2012-09-03 11:09:09 2012-09-03 11:14:09 N sysdate+1/(24*12) 0 dbms_refresh.refresh('"MVADMIN
"."REP_REFRESH"');
5,与刷新组相关的操作:
--新建一个刷新组
begin
DBMS_REFRESH.MAKE (
name => 'mvadmin.rep_refresh',
list => '',
next_date => SYSDATE,
interval => 'SYSDATE + 1/24',
implicit_destroy => FALSE,
rollback_seg => '',
push_deferred_rpc => TRUE,
refresh_after_errors => FALSE);
end;
/
--添加MV到一个刷新组
begin
DBMS_REFRESH.ADD(
name => 'rep_refresh',
list => 'tester.t1mv’
);
end;
/
--更改刷新组的刷新间隔
begin
DBMS_REFRESH.CHANGE(
name => 'rep_refresh',
next_date => sysdate,
interval => sysdate+(1/(24*60))
);
end;
/
--手动刷新一个刷新组
SQL> exec DBMS_REFRESH.REFRESH('rep_refresh');
---手动运行一个job
SQL> exec dbms_job.run(41);
--从刷新组中移除一个物化视图
begin
DBMS_REFRESH.SUBTRACT (
name => 'mvadmin.rep_refresh',
list => 'tester.t1mv’
);
end;
/
--移除所有的物化视图并删除刷新组
exec DBMS_REFRESH.DESTROY('rep_refresh');
6,物化视图对象的相关操作
创建物化视图日志表(一般在主站点操作):
CREATE MATERIALIZED VIEW LOG ON schema.object;
创建物化视图(一般在复制端进行):
CREATE MATERIALIZED VIEW schema.object
REFRESH FAST WITH PRIMARY KEY AS SELECT * FROM schema.object@dblink;
将物化视图添加到刷新组:
BEGIN
DBMS_REFRESH.ADD (
name => 'mvadmin.rep_refresh',-----刷新组名
list => ‘schema.object’, ----物化视图名
lax => TRUE);
END;
/
7,与物化视图相关的视图及相关包
user_mviews,dba_mviews
dba_jobs,dba_jobs_running
dba_refresh
user_refresh_children,dba_refresh_children
v$session,v$locked_object
dbms_refresh,dbms_mview,dbms_job
参考:http://blog.csdn.net/aqszhuaihuai/article/details/7207779