欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

想知道数据表的用户或系统异动时间

程序员文章站 2022-08-05 21:54:45
从这个表sys.dm_db_index_usage_stats可以获取到所有表或某一张表的用户或系统异动时间: SELECT OBJECT_NAME(object_id) AS table_name, last_user_seek, last_user_scan, last_user_lookup, ......

从这个表sys.dm_db_index_usage_stats可以获取到所有表或某一张表的用户或系统异动时间:

 

select object_name(object_id) as table_name, 
last_user_seek,
last_user_scan,
last_user_lookup,
last_user_update,
last_system_seek,
last_system_scan,
last_system_lookup,
last_system_update
from sys.dm_db_index_usage_stats
where database_id = db_id('dataname')
go