如何知道数据库中的更新表? [英] How to know the updated table in Database ?

查看:81
本文介绍了如何知道数据库中的更新表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的先生



我想在Sql Server中编写一个查询,它将显示数据库中表的更新数据。当我运行查询时,我将能够看到数据库中已更新的所有数据。



如果有任何疑问请帮助我.. < br $>




Sashibhusan Meher

Dear Sir

i want to write a query in Sql Server which will show updated data of a table in the database. When ever i run the query i will be able to see all the data that has been updated in the database .

if there is any query please help me ..


Sashibhusan Meher

推荐答案

如果你没有实施,你最好的选择表上的时间戳是使用工具浏览事务日志,请参见此处:



http://www.apexsql.com/sql_tools_log.aspx [ ^ ]
Your best option if you have not implemented timestamps on your tables is to use a tool to browse the transaction log, see here :

http://www.apexsql.com/sql_tools_log.aspx[^]


一种方法是为要跟踪更改的每个表写一个触发器。并创建另一个具有这种结构的表,可以存储所有已更改的数据。



有关触发器的信息:

http://www.go4expert.com/forums/showthread.php?t=15510 [ ^ ]



http://msdn.microsoft.com/en-us/magazine/cc164047.aspx [ ^ ]



另一种方式是在数据库中启用更改跟踪。要了解更多信息,请阅读:

http://www.databasejournal.com/features/mssql/article.php/3875186/A-Look-at-SQL-Server-2008-Change-Tracking.htm [ ^ ]



要比较这两种方法,请在此处阅读:

http://msdn.microsoft.com/en-us/library/cc280519% 28v = SQL.100%29.aspx [ ^ ]



希望有所帮助。
One way is write a trigger for every table in which you want to track the changes. And also create another table that has such a structure that can store all of your changed data.

For information about triggers :
http://www.go4expert.com/forums/showthread.php?t=15510[^]

http://msdn.microsoft.com/en-us/magazine/cc164047.aspx[^]

Another way is enabling Change Tracking in your database. to learn more about it read here :
http://www.databasejournal.com/features/mssql/article.php/3875186/A-Look-at-SQL-Server-2008-Change-Tracking.htm[^]

To have a comparison between these two methods read here :
http://msdn.microsoft.com/en-us/library/cc280519%28v=SQL.100%29.aspx[^]

Hope it helps.


取决于你的方式定义更新。从什么时候开始更新?



我会通过在数据库中添加一个反映最后一次更改的DateTime列来处理它。然后,我可以使用简单的SQL SELECT查询检索我需要的任何范围的更新记录。
Depends on how you define "updated". Updated since when?

I would handle it by adding a DateTime column to the database which reflects the last change. I could then retrieve only the updated records for whatever range I needed with a simple SQL SELECT query.


这篇关于如何知道数据库中的更新表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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