Basically, we have one table (original table
) and it is backed up into another table (backup table
); thus the two tables have exactly the same sche
select count(*)
from lemmas as original_table
full join backup_table using (lemma_id)
where backup_table.lemma_id is null
or original_table.lemma_id is null
or original_table.lemma != backup_table.lemma
The full join / check for null should cover additions or deletions as well as changes.