C
C
Che_Bu_Rashka2015-12-20 21:35:33
MySQL
Che_Bu_Rashka, 2015-12-20 21:35:33

How to receive notifications from the database when some table and/or field in the table is added/changed in the database?

How to receive notifications from the database when some table and/or field in the table is added/changed in the database? That is, the client uploads (Insert) or changes (Update) the data in the table, and an event is generated, to which another application is "subscribed" in some way, which spins right there on the same machine.
Any language, any database, but preferably PostgreSQL or MySQL. All that comes to mind is a poll after a short period of time using regular queries and comparing the new results with the result obtained last time. I think it's called Pulling? But this is how we torture the server. Or, as an option, monitor the physical files of the database using Watcher in Java, which can "see" events that signal a change in the file. notification

Answer the question

In order to leave comments, you need to log in

3 answer(s)
K
Kirill, 2015-12-21
@kshvakov

Postgres has a NOTIFY for this www.postgresql.org/docs/9.4/static/sql-notify.html

A
Anton, 2015-12-20
@hummingbird

triggers

S
Swartalf, 2015-12-21
@Swartalf

Correctly said, triggers.
As an option, create a trigger that inserts a row in a table with a log on the desired event.
An external script (by cron or daemon) works separately, which checks the table with the log for new entries and, depending on the type of entry, makes the necessary notifications.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question