Auditing data changes

This recipe provides different ways of collecting changes to data contained in the tables for auditing purposes.

First, you must make the following decisions:

  • Do you need to audit all changes or only some?
  • What information about the changes do you need to collect? Only the fact that the data has changed?
  • When recording the new value of a field or tuple, do you also need to record the old value?
  • Is it enough to record which user made the change, or do you also need to record the IP address and other connection information?
  • How secure (tamper-proof) must the auditing information be? For example, does it need to be kept separately, away from the database being audited?

Changes can be collected using triggers which collect ...

Get PostgreSQL 10 Administration Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.