We have a java application that updates / inserts values into the database.
we need to identify the tables it touches during an operation.
is there a way to find the list of tables the code updated/ inserted in the last one hour by a query ?
the database is sql server.
To get list of record for the past hour(x) from specific table
select * from table_name where Col_name> DATEADD(HOUR, -1, GETDATE())
to return list of tables modify past few hours
SELECT OBJECT_NAME(OBJECT_ID) AS DatabaseName, last_user_update,*
FROM sys.dm_db_index_usage_stats
WHERE database_id = DB_ID( 'dbName') and last_user_update> DATEADD(HOUR, -4, GETDATE())
I would simply do a compareTo(). But you'll have to do a timestamp for the database.
LocalTime thisSec;
for (;;) {
thisSec = LocalTime.now();
// implementation of display code is left to the reader
display(thisSec.getHour(), thisSec.getMinute(), thisSec.getSecond());
if (thisSec >= myDB.row(id).timestamp+1)
System.out.println(myDb.row(id));
}
Something like that anyway If you have a myDb.timestamp.row, that considers hrs,mins,secs, and you make .timestamp
that time, this should work.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.