MySQL Lists are EOL. Please join:

List:General Discussion« Previous MessageNext Message »
From:Martin Date:November 6 2004 11:49am
Subject:Reorder a table
View as plain text  
Hi all,

I have a problem with a news application, which writes news items into a
mysql table. Recently it gets confused, when it inserts new news items into
the table. I get the following exception:

"Duplicate entry '25' for key 1". root cause was java.sql.SQLException:
Invalid argument value, message from server: "Duplicate entry '25' for key
1" 

It seems that this application tries to overwrite existing news items and
mysql blocks this (which is very good actually). This is a problem with the
application, but I can't change this behaviour. I had a look at the table
and the primary key of the datasets is not available for all datasets, for
example I have primary keys 1 and 3, but not 2. So I could imagine that it
would help to reorder the table.

Could someone please tell me how to do the following with mysql? 
1) copy the old news table into a new one and in this new table:
2) order the datasets by timestamp
3) change the primary key (an integer) for all datasets, so that the oldest
datasets gets id 1

Many thanks
Martin

-- 
Geschenkt: 3 Monate GMX ProMail + 3 Top-Spielfilme auf DVD
++ Jetzt kostenlos testen http://www.gmx.net/de/go/mail ++

Thread
Reorder a tableMartin6 Nov
  • Re: Reorder a tableRhino6 Nov
    • Re: Reorder a tableMichael Stassen6 Nov
  • Re: Reorder a tableRhino6 Nov
Re: Reorder a tableMartin6 Nov
  • Re: Reorder a tableMichael Stassen7 Nov
Re: Reorder a tableBill Easton7 Nov