Solved

Import data - Problem with autoincrement field

Posted on 2004-09-19
1
271 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 26

Accepted Solution

by:
Umesh earned 125 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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

As a database administrator, you may need to audit your table(s) to determine whether the data types are optimal for your real-world data needs.  This Article is intended to be a resource for such a task. Preface The other day, I was involved …
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

627 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