I've got an assignment where I need to create a shell script to track just the changes to the employees table (DB2 database) record for any insert, delete or update that the HR department perform to users hourly.

No need for SQL or bash code. Just ideas on how to get this done.

Cons: I cannot edit or alter any DB schema or add/create any trigger.

Pros: I have the credentials to select * from the table

Is there any way I can achieve this without bringing all db records and compare them?

I just only need the new changes (update, insert or delete).

PS: I DO have a successful DB connection and already performing select queries.

Thanks for the time to look at the post.


  • Db2-LUW has an API (db2ReadLog/db2ReadLogNoConn) to read the transaction-logs , so you can filter what you need if you know how to program in a supported language. Refer to the Db2 Knowledge Center for details. Db2 also offers auditing functionality that can report such activities. Db2 also offers change-capture as part of the SQL Replication-functionality. The solution depends on the scale required, for trivial data volumes (e.g a few thousand rows) then export to CSV) with timestamp and diff may suffice for non-realistic or trivial situations.
    – mao
    Mar 14, 2018 at 11:35

1 Answer 1


I think the easiest way would be to configure db2 audit on this specific table and then analize audit logs/records according to what do you want to track.

Auditing can be configure to write to file and even syslog which simplifies things a lot.

  • You just do not neet to configure every single element of the db2audit. Start with one option, and then configure it according to your needs. db2audit can generate too much logs.
    – AngocA
    Mar 27, 2019 at 20:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .