`
xiechangming
  • 浏览: 26644 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

Database Change Notification

阅读更多

    Database Change Notification is a feature that enables client applications to register queries with the database and receive notifications in response to DML or DDL changes on the objects associated with the queries. The notifications are published by the database when the DML or DDL transaction commits.

    Once use this feature for change notification of column level, and found that once the amount of updated records  is more than  a small value during a transaction, such as 200, then the change notification considers the corresponding tables are fully updated and it consumes much database resources, such as CPU time, I/O throughput, etc, so just as Oracle official document said, For best performance of change notification, Registered objects are few and mostly read-only and that modifications to those objects are the exception rather than the rule. If the object is extremely volatile, then it  cause a large number of invalidation notifications to be sent, and potentially a lot of storage in the invalidation queue on the server. If there are frequent and a large number of notifications, it can slow down OLTP throughput due to the overhead of generating the notifications.

The following is the example of how to use database change notification:

1. create a demo table and inset data into the table

create table RTM_CHANGE_NOTIFICATION

(

  COL1 VARCHAR2(100),

  COL2 VARCHAR2(100),

  OID  NUMBER(20) not null

);

 

declare

begin

 

for rec in 1..100 loop

 

insert into rtm_change_notification (col1,col2,oid) values('XIECH2'||rec,'FLOYD'||rec,rec);

 

end loop;

 

commit;

end;

 

2. prepare plsql callback procedure

Create table nfcount(cnt number);

Insert into nfcount values(0);

Commit;

 

CREATE OR REPLACE PROCEDURE proc_chnf_callback (ntfnds IN SYS.CHNF$_DESC)

IS

BEGIN

update nfcount set cnt = cnt+1;

commit;

END;

/

 

3. Register query

-- procession for registration and deregister

------------------------------------------------------------------------------

-- registration

declare

  lv_reg_info sys.chnf$_reg_info;

  lv_reg_id number;

  lv_qosflags number;

  lv_temp varchar2(3000);

  lv_operations_filter number;

begin

  lv_qosflags := dbms_change_notification.QOS_ROWIDS;

  lv_operations_filter := dbms_change_notification.INSERTOP+dbms_change_notification.UPDATEOP+dbms_change_notification.DELETEOP ;

  lv_reg_info := sys.chnf$_reg_info('proc_chnf_callback',lv_qosflags,0,lv_operations_filter,0);

  lv_reg_id := dbms_change_notification.NEW_REG_START(lv_reg_info);

  -- register tables

  select t.col1 into lv_temp from rtm_change_notification t where t.col1 = 'XIECH24'; 

  dbms_change_notification.REG_END;

end;

/

4. Check the registration

select r.* from user_change_notification_regs r;

5. Verify the registration

insert into rtm_change_notification values('1','2',10010 );

commit;

 

select * from nfcount;

6. Deregister

declare

  lv_reg_id number := reg_id;/*the reg_id could be get by query user_change_notification_regs */

begin

  dbms_change_notification.DEREGISTER(lv_reg_id);

end;

/ 

0
0
分享到:
评论

相关推荐

    java实现监听数据库源码

    Java 6引入了一个新的特性——Java Database Change Notification,允许应用程序订阅数据库的改变。当数据库中的指定表发生变化时,JDBC驱动会通知订阅者。这是一个相对低级别的API,需要对数据库驱动有深入理解...

    ojdbc6.jar

    此外,还有`oracle.jdbc.dcn.DatabaseChangeEvent`和`oracle.jdbc.dcn.DatabaseChangeRegistration`等类,用于支持数据库变化通知(Database Change Notification, DCN),这是一种高效的方式,让应用能在数据库发生...

    cx_oracle help

    ### Database Change Notification 数据库变更通知(DBCN)功能允许应用程序订阅对特定表或对象的更改,并在数据库中发生更改时接收通知。这对于实现实时应用或者数据同步非常有用。 ### Database Resident ...

    Web-Scale PHP Database Connection Management

    #### 数据库常驻连接池(Database Resident Connection Pooling - DRCP) - **概念**: DRCP是一种优化机制,可以在数据库服务器上保留一定数量的空闲连接,以便快速响应新的请求。 - **优势**: 减少了连接建立和销毁的...

    ojdbc6-11.2.0.1.0.zip

    4. `oracle.jdbc.dcn` 包:提供了数据变化通知(Data Change Notification,DCN)功能,使得应用程序可以订阅数据库的更改事件。 5. `oracle.jdbc.OracleCallableStatement` 和 `oracle.jdbc....

    monitor-table-change-with-sqltabledependency:获取记录表更改时SQL Server通知

    监视和接收有关记录表更改的通知 SqlTableDependency是一个高级C#组件,用于审核,监视和接收有关SQL Server记录表更改的通知。 对于任何记录表更改,作为插入,更新或删除操作,包含更改记录值的通知将传递到...

    rx第三方控件

    TRxFolderMonitor component provides notification if any changes matching the filter conditions occur in the specified directory or subtree. TRxTrayIcon component enables 32-bit applications to add ...

    Maian Guestbook v1.1留言本.rar

    -Receive notification if someone signs your guestbook. (optional) -Visitors can add BB Code to posts. -Send 'Thank You' message to visitors. (optional) -Easily add banner or text link to top of ...

    随时间变化提示.rar

    10. **实时数据库**:像Firebase Realtime Database或MongoDB的Change Streams这样的实时数据库,能够实时跟踪数据变化,并提供订阅机制,让应用能够即时响应。 综上所述,“随时间变化提示”涵盖了编程中的多个...

    Oracle数据库创建用户与数据库备份小结(必看篇)

    - `CHANGE NOTIFICATION`允许用户注册和接收改变通知。 - `CREATE ANY DIRECTORY`允许用户创建任何目录对象。 - `CREATE ANY TABLE`允许用户创建任何表。 - `DROP ANY DIRECTORY`允许用户删除任何目录对象。 - `...

    基于python+Django的校园疫情监控平台设计与实现.docx

    4. 预警与通知模块 (Alert and Notification Module): Whenever there is a significant change or risk, such as a new case or a spike in infections, the system triggers alerts to relevant parties, ...

    添加一个radius_authenticatable模块以与设计一起使用.zip

    config.send_password_change_notification = false config.storage = :active_record config.sign_out_via = :delete config.register_module :radius_authenticatable ``` 3. **创建User模型**: 如果还...

    linux 命令英文全称

    biff是邮件通知功能(mail notification feature)的一部分,在某些早期的电子邮件客户端中使用。 #### cal=CALendar cal(Calendar)命令用于打印日历。 #### cat=CATenate cat(CATenate)命令用于连接文件并打印到...

    RxLib控件包内含RxGIF,全部源码及DEMO

    TRxFolderMonitor component provides notification if any changes matching the filter conditions occur in the specified directory or subtree. TRxTrayIcon component enables 32-bit applications to add ...

    DuckieTV - 浏览器按钮“模式 -crx插件

    added upgrade check and notification, and zoom control is now 1:1 with chrome browser - Database performance improvement (including less frequent ratings updates) - added 'Watch on Netflix' button ...

    IRPTrace2.00.002.zip

    GUID.INI - GUID database IRPTRACE.INI - Driver uninstallation information UNINST.ISU - Installation/uninstallation log file 2) Release Notes ================ Release 2.00.002 1. Fixed ...

    实时应用

    7. **数据库集成**: 实时应用往往需要与实时数据库配合,例如Firebase Realtime Database或MongoDB的Change Streams,这些数据库能够监听数据变化并立即通知应用,确保数据的一致性和即时性。 8. **推送通知服务**:...

Global site tag (gtag.js) - Google Analytics