Answer the question
In order to leave comments, you need to log in
How is it easier and more correct to transfer one record from a backup?
Hello sql gurus. There is such a problem - the admin removed one necessary user from the database. There is a backup and now you need to get this user out of this backup. The problem is that there are many tables in the database that refer to the users table (user messages, orders, etc.). Is it possible to pull out all the data on the user and links to it with one command, so that later they can be inserted into the current database? Or do you need to separately go through all the tables and look for links to the desired user_id there and insert them into each one separately?
Thanks in advance.
Answer the question
In order to leave comments, you need to log in
No, naturally. No one knows what kind of structure you have and in which tables what lies.
Need to find.
Alternatively, the admin could delete the user without deleting his messages and orders.
Well, you have to look at it.
If you have custom software, then just climb yourself and look for everything.
If the backup is fresh enough, you can compare the backups (each table line by line, but this operation is quite simple and the script can be generated based on the structure, pulling it out of ddl, but the structure is not needed here), if you look for the difference what exactly is deleted (what is in backup but not in the current database, do a check by the id field (the one that is the primary key, ddl is needed precisely to identify composite ones), the databases can be deployed on one server), then you can get a completely ready-made slice of records, it will be much easier to view them with your eyes than the entire database entirely.
look at pgdiff
The smaller the distance in changes between the backup and the current database, the fewer extra entries will result.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question