I want to know how to find when was a Teradata table was last UPDATED. Everywhere I look I am getting when was it last Altered. Is updated the same as Altered?
I got the code for Alter table:
SELECT TABLENAME, LASTALTERTIMESTAMP
FROM DBC.TABLES
WHERE DATABASENAME = 'Schema'
AND TABLENAME = 'table'
ORDER BY LASTALTERTIMESTAMP DESC
What is it for UPDATE table? Thanks
In terms of SQL requests, UPDATE
and ALTER
are two different things. ALTER
modifies the table structure ( DDL
) -- ie adding / modifying a column. UPDATE
modifies the table data ( DML
) -- ie adding / deleting rows.
As far as I remember, there's no easy way to see when a table was last modified (updated) unless you add some custom auditing fields (ie lastAlterTimestamp
) that you set each time you write to the table.
IF you want to know when a table was updated, you might think about using a trigger.
Good day!
To find the time the table last was updated, you can try to parse query log table. For example, let your table name is TNAME and it is located in schema SNAME.
So you can use the following query:
select
username,
firststeptime,
querytext
from pdcrinfo.dbqlobjtbl_hst
where
statementtype = 'Update'
and querytext like 'insert into SNAME.TNAME%'
qualify row_number() over (partition by 1 order by firststeptime desc) = 1
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.