mysql中怎样更新表if标签_如何知道是否更新了mysql表?

Actually I use the following sentence read on another question in this page:

實際上,我在這頁的另一個問題上用了以下句子:

SELECT UPDATE_TIME

FROM information_schema.tables

WHERE TABLE_SCHEMA = 'dbname'

AND TABLE_NAME = 'tabname'

But I think that it is using a lot of process time, it will be more easy if mysql-server sends me a signal when the table is updated so I can wait until my program detects that signal.

但是我認為它需要大量的處理時間,如果mysql-server在更新表時向我發送一個信號,我可以等待,直到我的程序檢測到那個信號。

Is this possible? I'm programming in C.

這是可能的嗎?我在C編程。

Thank you very much.

非常感謝。

1 个解决方案

#1

4

You can use a trigger combined with a UDF progammed in C(++) to do the notification.

Here's dummy code.

您可以使用一個觸發器和一個UDF在C(++)中的progammed來完成通知。這是偽代碼。

DELIMITER $$

CREATE TRIGGER ai_table1_each AFTER INSERT ON table1 FOR EACH ROW

BEGIN

CALL ChangeNotification('table1', 'insert', NEW.id);

END $$

DELIMITER ;

You'll have to do a trigger for insert/delete and update. 3x per table.

You cannot add a trigger to the system tables IIRC, because these are really views and not actual tables.

你必須為插入/刪除和更新做一個觸發器。3 x每桌。不能向系統表IIRC添加觸發器,因為這些實際上是視圖,而不是實際的表。

You'll need to write a UDF in C(++) called changenotification that does the notification for you.

您需要用C(++)編寫一個UDF,名為changenotification,它為您提供通知。

鏈接:http://dev.mysql.com/doc/refman/5.0/en/adding-udf.html http://www.mysqludf.org/ http://dev.mysql.com/doc/refman/5.0/triggers.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值