This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC and the fly likes auto_increment in mySql Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "auto_increment in mySql" Watch "auto_increment in mySql" New topic

auto_increment in mySql

Peter Primrose
Ranch Hand

Joined: Sep 10, 2004
Posts: 755
Hi All,

is there any way to auto_increment backwards (-1, -2, -3) in mysql?
or to have an ID which increments like this:

Steven Bell
Ranch Hand

Joined: Dec 29, 2004
Posts: 1071
I don't think this is possible within MySQL, or any other DB that I know of. If you are using hibernate you could write your own id generator. Otherwise I think you would have to lock the table, query for the last id, then generate the next one all in your java code.
I agree. Here's the link:
subject: auto_increment in mySql
Similar Threads
inserting data of two forms into two tables with same transaction id
auto_increment primary key
How to create a sequence in MySql5.0
MySQL auto_increment and EJB
MySQL + Eclipselink - SEQUENCE table