Jump to content

What's the difference between the export SQL dump type used in PhpMyAdmin?


joseph

Recommended Posts

In PhpMyAdmin we have these 3 export options to choose from: 1. Insert 2. Update and 3. Replace. Sound very easy to understand but how is it done exactly to the tables having an existing data?

 

For sure, I know the most common when we use INSERT Export type to an existing database, it will insert it all w/o errors that is if the tables being inserted to the new database does not have any identical table_names.

 

How about for the UPDATE and REPLACE? How will it react when we insert them to the new database if there are identical table_names?  ???

 

 

Link to comment
Share on other sites

  • 5 years later...

Let me explain what I am after a little better. I have a live database which I exported to my development machine. While it was there I added a few new tables, a few fields in existing tables, and deleted a bunch of really old records that nobody will ever need. I'd love to be able to export from the development machine, import to my test server, have the new tables added (easy), have the tables with new fields updated, and have the junk records deleted. I think that I need to actually write SQL myself to do the last two things though. Am I wrong?

Link to comment
Share on other sites

  • 3 weeks later...

Basically

 

INSERT inserts new records

UPDATE updates existing records

REPLACE inserts if record is not there and updates if it is (based on primary key match)

Just to clarify, REPLACE does not update the old record. REPLACE will delete the old record and insert a new one. Be careful using REPLACE INTO if you have other tables that are referencing it.

Link to comment
Share on other sites

Am I correct that there is no option that will delete a record if it no longer exists in the copy that is being imported?

If you just want the imported records and only those imported records, PHPMyAdmin has the option of adding the "DROP TABLE" statement. This is essentially like restoring a backup. I would be very careful doing this on a production site though.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.