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
Solved

Import data - Problem with autoincrement field

Posted on 2004-09-19
1
267 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Foreword In the years since this article was written, numerous hacking attacks have targeted password-protected web sites.  The storage of client passwords has become a subject of much discussion, some of it useful and some of it misguided.  Of cou…
I have been using r1soft Continuous Data Protection (http://www.r1soft.com/linux-cdp/) for many years now with the mySQL Addon and wanted to share a trick I have used several times. For those of us that don't have the luxury of using all transact…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

838 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