将行插入表的日期 [英] Date of inserting a row into table

查看:33
本文介绍了将行插入表的日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 SQL Server 2005 中,是否可以找到将行插入到表中的日期+时间?

Is it possible to find date+time when a row was inserted into a table in SQL Server 2005?

SQL Server 是否记录插入命令?

Does SQL Server log insert commands?

推荐答案

每当我创建表格时,我总是包括以下两列:

Whenever I create a table, I alway include the following two columns:

CreatedBy varchar(255) default system_name,
CreatedAt datetime default getdate()

虽然这会占用一些额外的空间,但我发现随着时间的推移,这些信息证明非常非常有用.

Although this uses a bit of extra space, I've found that the information proves very, very useful over time.

您的问题是关于日志的.答案是是".但是,您是否可以获得信息取决于您的恢复模式.如果简单,则记录将被下一个事务覆盖.如果批量或完整,则信息在日志中,至少自上次增量备份以来是这样.

Your question is about the log. The answer is "yes". However, whether you can get the information depends on your recovery mode. If simple, then the records are overwritten for the next transaction. If bulk or full, then the information is in the log, at least since the last incremental backup.

这篇关于将行插入表的日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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