DG环境下通过心跳表从业务角度监控数据同步
我们通过一个例子演示如何创建心跳表,以及如何执行定时任务来更新心跳表相关字段。
SQL> show user
USER is "SYS"
1 创建测试表
SQL> create table dg_heartbeat tablespace users as
select dbid, name, sysdate as last_update from v$database;
Table created.
SQL> select * from dg_heartbeat;
DBID NAME LAST_UPDATE
---------- ------------------------------ ---------------
2727953090 ZDHYJL 20200429 101928
2 定时job更新心跳表中的计时字段
SQL> var job number
SQL> exec dbms_job.submit(job => :job, what => 'update dg_heartbeat set last_update=sysdate;', next_date => trunc(sysdate, 'MM') + 1/1440, interval => 'sysdate + 1/1440');
PL/SQL procedure successfully completed.
SQL> print job
JOB
----------
1301
SQL> commit;
相关文章