Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: mySQL, Java & rollback behavior



I believe this is normal, if annoying, mysql behavior: auto increment fields only ever go up. There may be an easier solution, but you should be able to do something like:

    ALTER TABLE table_name SET AUTO_INCREMENT=100;

to reset the counter. In practice, of course, you'd use the result of something like "SELECT MAX(key_field) FROM table;" instead of "100".

Philip

On Sep 30, 2008, at 6:39 PM, Michael Hall wrote:


On Sep 30, 2008, at 3:41 PM, Kevin Muldoon wrote:

I'm able to rollback unwanted edits to a mySQL table with Java but I notice that the primary key ( id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY) does increment although the rollback is successful.

In other words, if the PRIMARY KEY is 100 and user rollsback on three records then the next insert will generate 104 rather than a nice and neat 101. I wanted to know if this behavior can be handled or do us developers just "live with it".

Does it work any different from Terminal if you just enter the SQL there, is it mysql or java?
Your primary key should just ensure uniqueness shouldn't it? It wouldn't be anything you would select or report on so it doesn't really matter much does it?


Mike Hall        hallmike at att dot net
http://www.geocities.com/mik3hall
http://sourceforge.net/projects/macnative



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden

_______________________________________________ Do not post admin requests to the list. They will be ignored. Java-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden
References: 
 >mySQL, Java & rollback behavior (From: Kevin Muldoon <email@hidden>)
 >Re: mySQL, Java & rollback behavior (From: Michael Hall <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.