oracle物化视图快速更新

前端之家收集整理的这篇文章主要介绍了oracle物化视图快速更新前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

建立测试表

createtableT_tablenologgingasselect*fromdba_objects;
createtablet_table_1nologgingasselect*fromdba_tables;

--建立日志记录

creatematerializedviewlogonT_tablewithrowid,sequence(object_name,object_type,owner)includingnewvalues;
creatematerializedviewlogont_table_1withrowid,sequence(table_name)includingnewvalues;

--建立物化视图

creatematerializedviewmv_t_tablenologging
refreshfastondemand
withrowid
STARTWITHTO_DATE('21-08-201710:09:08','DD-MM-YYYYHH24:MI:SS')NEXTSYSDATE+1/(24*60)
asselectcount(*),a.object_type,a.ownerfromT_tablea,t_table_1bwherea.object_name=b.table_name
groupbya.object_type,a.owner


--测试

select*frommv_t_tablewhereowner='SYSTEM';
deletefromt_tablewhereowner='SYSTEM';
insertintot_tableselect*fromdba_objectswhereowner='SYSTEM';


--查看日志生成

selecta.name,b.valuefromv$statnamea,v$mystatbwherea.statistic#=b.statistic#anda.name='redosize';


--查看刷新日志

SELECTowner,mview_name,last_refresh_scn,last_refresh_date,query,REVISIONFROMdba_mview_analysisWHEREowner='UTF32';

--查看日志记录表,MLOG$为日志记录表,一旦更新完成,此表的内容会被清掉;

select*fromMLOG$_T_TABLE
select*fromMLOG$_T_TABLE_1;

官方说明参见:http://docs.oracle.com/cd/E11882_01/server.112/e10706/repmview.htm#REPLN265

原文链接:https://www.f2er.com/oracle/208007.html

猜你在找的Oracle相关文章