There is a LocalDB database, it receives data and this data changes, what methods are there to track which rows in the tables have changed. For example, I loaded the data into the database tables, I work with the data, then I need to take data from the database and send it to another place (not where), the question arises, take all the data from all the tables and send to the addressee or it’s more logical to track the change and take only changed data. How can you organize such a process. Add a flag to each row of the table? I want to do something like a mechanism using the base itself.
- oneYou can perform your actions when changing / deleting / inserting records with the help of so-called triggers . But you do not need triggers, you need synchronization. Usually you need to provide a set of data to synchronize, for example, the date-time of the creation of the record. In complex cases, this can result in storing change events instead of entities . There is no simple answer, you have to read a lot and experiment. - Mark Shevchenko
- oneThere is another option with triggers plus service table. To which the trigger simply writes the ID of the changed record, if it is not there yet. And for synchronization, upload records, the ID of which is in the table, then clean the table - let the following modified ones accumulate. As experience shows, this is more efficient than the field (of the change or time stamp of the actualization) in the table itself. - Akina
- oneHow does the trigger track that the entries in the tables have changed? No It simply triggers on the specified action, and at the same time has access to the initial and final state of either each variable record, or the entire array at once. - Akina
- 2look docs.microsoft.com/en-us/sql/relational-databases/track-changes/… - PashaPash ♦
- oneSqlDependency - Alexander Petrov
|