Pre story. There was a database (test_db), made its backup. After a backup, one million data was deleted in one of the tables. A month has passed. Now we need to return this data back. I restored a previously made backup in which these records were and deployed it to a separate database with a new name (test_db_new). The request to fetch data from the restored table (test_db_new) is, what kind of query can I ADD the selected data to the table (test_db)?

    1 answer 1

    Use INSERT INTO ... SELECT

    INSERT INTO test_db_new.table (Column1, Column2) SELECT column1, column2 FROM test_db.table WHERE 1 = 1; 

    Copies and between different databases, see here: https://stackoverflow.com/q/22912167/5752652

    • Why WHERE ? - Anton Shchyrov
    • @AntonShchyrov I wanted to show that there will be some condition that selects remote ID's, such as id> 100 and id <200 - AK
    • The author should be the other way round - not into a temporary base from a battle base, but from a temporary base to a battle one. It also copies between different databases - but you need to make a reservation that it is strictly within the framework of a MySQL server instance. And that was a fun occasion ... - Akina
    • Thank you all, figured out. But now the problem is with XML type fields. (( Ru.stackoverflow.com/questions/755511/… - Damir Gabdullin