jQuery in Action, 3rd edition
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.
It is sorta covered in the JavaRanch Style Guide.
subject: auto_increment in mySql
jQuery in Action, 3rd edition