S
S
Sergey Brovko2019-12-16 13:11:03
PostgreSQL
Sergey Brovko, 2019-12-16 13:11:03

How to manually check DB foreign keys?

Hello. I understand that the question may be banal or vague, but the situation is as follows:
There are several database tables that are filled from the client side, the client often messes with the data. tables are linked to others using foreign keys, data is transferred via logical replication to another database (on another server). The problem is that they started to accidentally catch cases when there is a record in the table, but there is no record by the key to which it refers. Is it possible to check the keys of a particular table at once (to find out if there is a record referenced by a key in another table)? Or at least for one specific key? Tell a query. "Shortage" revealed in the process of importing a database dump on another server.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Tikhonov, 2019-12-16
@cyber01

LEFT JOIN on foreign key and check for NULL

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question