检查 sybase table 之前是否更新

Check if sybase table updated previously

我很好奇是否有办法知道以前是否更新/添加了 sybase table? table 是通用的,我不允许使用触发器或创建类似 updateDate 字段的内容。检查行数更改不是一个选项。

我的第一个想法是检查 sysobjects table,但从我使用下面的 sql 看到的情况来看,我认为没有存储任何有用信息的列来解决我的问题。

select name,userstat,uid, type, sysstat, indexdel, schemacnt,sysstat2,sysstat3, crdate,expdate,deltrig,instrig,ckfirst,cache, objspare,versionts,loginame,identburnmax,spacestate,erlchgts,lobcomp_lvl
from sysobjects o where type = 'U'

关于如何知道 table 是否已更新的任何其他想法?

找到了使用 datachange 函数的方法。

select convert(varchar(30),o.name) AS table_name,
row_count(db_id(), o.id) AS row_count,
datachange('AAA_TABLE', null, null) AS changes
from sysobjects o
where type = 'U' and o.name='AAA_TABLE'
order by table_name

更新 table 之前的结果是:

更新后 SQL :

update AAA_TABLE set TYPE='1234' where ID=1 //previously TYPE was 1233

结果更改为:

字段 "changes" 已更新为新值,似乎这是一个不错的解决方案,但我仍然对任何其他想法持开放态度。

如果您的数据库管理员设置了每天更新 systabstats,您可以使用以下查询获取 table 的最后 modified/updated 日期。

select MAX(statmoddate) as last_modified_date
from systabstats
where id = object_id('table_name')