Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9042803
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T10:35:17+00:00 2026-06-16T10:35:17+00:00

This is a follow up question to my prev one. I use the code

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T10:35:18+00:00Added an answer on June 16, 2026 at 10:35 am

    Use LOCK TABLES

    // duplicate tables structure 
    $query = "CREATE TABLE $this->dbName.`$newTableName` LIKE $this->dbName.`$oldTable`";
    
    // lock source and target table
    $query = "LOCK TABLES $this->dbName.`$newTableName` WRITE, $this->dbName.`$oldTable` AS source WRITE";
    
    // duplicate tables data
    $query = "INSERT INTO $this->dbName.`$newTableName` SELECT * FROM $this->dbName.`$oldTable` AS source";
    
    // unlock
    $query = "UNLOCK TABLES";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a follow-on question from the one I asked here . Can constraints
This is a follow-up question related to my previous post . Below is a
This is a follow-up question to this one . Consider this example: #include <iostream>
This is like a follow-up question to this one . Basically what I'm doing
(This is a follow up question to this one.) I'm having a problem with
This is a follow-up question to Merging multiple encoded polylines into one encoded polyline
This is a follow up question to this one: Syntax confusion (do block) So,
This is a follow-up question to this one: Check for specific integer in a
This is a follow up question to the one answered here: Excluding dates from
This is a follow up question to : Transactions in REST? How does one

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.