MySQL Forums
Forum List  »  General

Re: duplicate entry for key
Posted by: Todd Farmer
Date: July 27, 2010 11:36AM

Hi abhi,

abhi mahajan Wrote:
-------------------------------------------------------
> 'uname' is set as unique
...
> 1. after filling the entries in java application
> and after successful entry in table, i get an
> exception message after closing application as:
> "exception occurs : duplicate entry 'lambda' for
> key 2"
> this whole entry is successfully inserted into
> table. so what is the meaning of 'duplicate entry'
> nd why is it happening??

Because there were two INSERT statements with a "uname" column value of "lambda". Enable the general query log if you need to see the commands actually received by the server.

> 2. suppose i inserted a row in table through
> application, after successful entry in table i get
> an new eid as 106 (say), means that last entry of
> table had eid content as 105. nw if i delete this
> account i.e. with eid as 106 and then re-enter new
> values in table, i get the new eid as 107 instead
> of 106 which ws deleted previously. why is this
> happening nd what could be done to avoid this??

You don't want to do this, really. MySQL won't recover and reuse auto-increment values after rows have been DELETEd. You could, conceivably, issue ALTER TABLE statements to reset the auto-increment counter, but just don't do it. Take a long hard look at why your application needs to do this.

Options: ReplyQuote


Subject
Written By
Posted
July 24, 2010 07:14AM
Re: duplicate entry for key
July 27, 2010 11:36AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.