Recently my team have get a situation in which some records in our shared test database disappear with no clear reason. Because it’s a shared database (which is utilized by so many teams), so that we can’t track down if it’s a programming mistake or someone just run a bad sql script.
So that I’m looking for a way to notify (at database level) when a row of a specific table A get deleted. I have looked at the Postgres TRIGGER, but it failed to give me the specific sql that cause the deletion.
Is there anyway I can log the sql statement which cause the deletion of some rows in table A?
You would do this to the actual postgres config files:
http://www.postgresql.org/docs/9.0/static/runtime-config-logging.html
You want either ddl or all to be the selection. This is what you need to alter:
In your
data/postgresql.conffile, change thelog_statementsetting to ‘all’. Further the following may also need to be validated:taken from here