Update modification timestamp on DB2 table automatically

Ever want to update your modification timestamp field any time an update is made to the row without having to add application logic? Well, DB2 makes it relatively painless…

alter table XX.MY_TABLE add column last_updated_ts timestamp not null
generated by default for each row on update as row change timestamp

Check out these resources for additional information…

  • https://www.ibm.com/support/knowledgecenter/SSEPGG_11.1.0/com.ibm.db2.luw.admin.dbobj.doc/doc/c0051498.html
  • https://www.ibm.com/support/knowledgecenter/SSEPGG_11.1.0/com.ibm.db2.luw.sql.ref.doc/doc/r0000888.html
Please remember to subscribe to the newsletter to stay up to date!

You or someone you know looking to buy or sell?
Disclaimer: Thoughts and opinions are my own, and do not reflect the views of any employer, family member, friend, or anyone else. Some links may be affiliate links, but I don't link to anything I don't use myself. You would think this should be self evident these days, but apparently not...

Leave a Reply