File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes auto_increment in mySql Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
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
It's not a secret anymore!