This is a follow up question to my prev one.
I use the code below to duplicate database tables, but sometimes if the table size is large, the script hangs and the page just keeps waiting, and when I compare number of rows in both table I find something similar to this
Original table count: 855057
Backed up table count: 855022
So it seems like the process did not fully complete which brings up the questions, why it got stuck during executing of insertion statments?
Keep in mind that in most cases both counts actually the same, still, it hangs even though it finished duplicating.
Here’s my code:
//duplicate tables structure
$query = "CREATE TABLE $this->dbName.`$newTableName` LIKE $this->dbName.`$oldTable`";
..
..
//duplicate tables data
$query = "INSERT INTO $this->dbName.`$newTableName` SELECT * FROM $this->dbName.`$oldTable`";
..
..
ps. I run the duplicating script from my localhost to backup db located in remote server.
Use LOCK TABLES