使用C#轮询方法监视mysql数据库和表更新 [英] Monitoring mysql database and table updates using C# polling method

查看:819
本文介绍了使用C#轮询方法监视mysql数据库和表更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用C#轮询方法监控mysql数据库和表更新



我需要监控MySql数据库并记录删除,更新等操作完成与否? br $>


我的Myhr数据库中有很多表,但是想创建一个控制台应用程序,它监视Myhr数据库并检查是否有任何更新或删除。如果是,则必须返回该值(操作完成)。



代码示例将非常有用。

Monitoring mysql database and table updates using C# polling method

I need to monitor MySql database and log the delete, update, etc. operations done or not?

I have many tables in my Myhr database, but want to create a console application, which monitor Myhr db and check if there is any update or deletion is done. If yes, then it must return that value(the operation done).

Code samples will be of great use.

推荐答案

这不是一个真正的问题,它更多的是需求列表,你要求一些代码,所以除了你试图这样做。我建议您阅读有关如何在此论坛上提问的常见问题解答,因为它将指导您提出更有可能获得解决方案的问题。



As对于你的问题,如何在数据库上使用触发器。

Mysql触发器 [ ^ ]



您可以在数据库中的每个表上设置触发器,以更新任何更改的日志表。我个人认为必须监控每张桌子都是过度杀戮。



但是如果不知道你的数据库设计,建议并不容易。我也看不出需要这种监控的原因?



触发器的另一种选择是,每次你的应用程序保存数据时,它都会向日志表,您只需定期轮询日志表以查看是否有新条目。同样,这消除了监视每个表的需要,但只是监视器1。
This is not really a question, it more a list of requirements and you asking for some code so save you trying to do it. I suggest that you read the FAQ on how to ask questions on this forum as it will guide you towards asking questions that you are more likely to get solutions to.

As for your problem, what about using Triggers on the database.
Mysql Triggers[^]

You could set up a trigger on every table in your database to update a log table with any changes. Personally I think it is over kill to have to monitor EVERY table.

But without knowing your database design it is not easy to advise. I also cannot see a reason for needing this sort of monitoring?

An alternative to the triggers, is that each time your application saves data, it writes an entry to the log table and you just poll the log table on a regular basis to see if there are new entries. Again, this removes the need to monitor every table but just monitor 1.


这听起来像是一场灾难,想到的第一个问题是为什么。



如果MySQL支持触发器,则将更改插入日志表并查询日志表。



我们使用它来保存和审核变更,但我绝不会考虑轮询表格。我们允许用户根据一系列标准查询日志表。
This sounds like a disaster in the making, the first question that come to mind is WHY.

If MySQL supports triggers then insert the changes into a log table and query the log table.

We use this to keep and audit of changes but I would never consider polling the table. We allow the user to query the log table based on a bunch of criteria.


这篇关于使用C#轮询方法监视mysql数据库和表更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆