Sql-server – Database events but not triggers

elasticsearchoraclesql server

This is a question regarding general DB inner workings, not particular to an implementation or paradigm, though answers for certain technologies are welcome.
I am asking if there is a way to listen to what commands the database has received, or something like read an inner log of the database, at least the last changes.
I need such a functionality to be able to find if there were changes to a table and if so, read the particular row that has changed. It is assumed changes to the columns are not to happen.
I am only a listener of the database, hence I am not able to program triggers.

Best Answer

Most major DBMS products today have facilities for this: it may be called

  • Change Data Capture (Oracle, SQL Server)
  • logical replication (Postgres, MySQL)

Most of these facilities operate on the publish/subscribe model and build upon the DBMS's built-in transaction logs to provide a stream of change events. Often the amount of logging will increase slightly because the primary key has to be included in the stream rather than just physical information about which blocks have changed.

Organisationally, you may encounter resistance to implementing things like this with conservative DBAs and organisations (I have encountered this several times when trying to implement Oracle CDC), while it's not likely to be an issue where they have switched to, or are using open-source DBMSes (more open to change).