Solved

Import data - Problem with autoincrement field

Posted on 2004-09-19
1
268 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:
ushastry 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

All XML, All the Time; More Fun MySQL Tidbits – Dynamically Generate XML via Stored Procedure in MySQL Extensible Markup Language (XML) and database systems, a marriage we are seeing more and more of.  So the topics of parsing and manipulating XM…
I use MySQL for many of my development projects in a Windows environment. To manage my databases (and perform queries) for years I used a tool called MySQL administrator.  This tool has since been replaced by MySQL Workbench. So I decided to m…

713 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