Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Import data - Problem with autoincrement field

Posted on 2004-09-19
1
Medium Priority
?
273 Views
Last Modified: 2010-05-18
Hi.

Let's say i have TABLE-1 in mysql-server1 with 2 columns :

id PRIMARY auto-increment.
name TEXT

In TABLE-1 i have 2 rows

id  name
1   JOHN
2   MIKE

If i make an export of TABLE-1 in mysql-server2 with mysqldump, i get a file that contain
INSERT INTO TABLE-1 VALUES (1,'ROBERT');
INSERT INTO TABLE-1 VALUES (2,'JASON');


How could I do to import data from mysql-server2 without having problem with "DUPLICATE KEY" of id.

Can i get this export with mysqldump, typing a specific option ?? : (that would solve my problem)
INSERT INTO TABLE-1 VALUES ('','ROBERT');
INSERT INTO TABLE-1 VALUES ('','JASON');

Or do i need to do something while importing.


My real world table have many columns and about 600Mb of data, so i need an adapted solution.

Thanks



0
Comment
Question by:eeolivier
1 Comment
 
LVL 26

Accepted Solution

by:
Umesh earned 250 total points
ID: 12099155
HI,

Make a backup of the database before doing anything here..

I guess your import file is something like this.. say dump.sql .. and make sure the autoincrement column looks like ''

INSERT INTO TABLE-1 VALUES ('','ROBERT');
INSERT INTO TABLE-1 VALUES ('','JASON');
then use this command to insert/import..

mysql -u USER -p DBNAME < dump.sql

0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month12 days, 7 hours left to enroll

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question