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