Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options answers only not deleted user 61

Numerical sequence generation for automatic key creation

1 vote

Unique code based on category - a sort of auto_increment

Assuming you are using an ACID compliant engine (i.e. InnoDB) the "get max, add one, then insert" method should work if wrapped in a transaction. I would query the requirement for the user code to be …
David Spillett's user avatar
5 votes
Accepted

MySQL auto_increment delivers different primary key in MyISAM and InnoDB

All you can guarantee with an auto-increment is that (unless you jiggle about with it to reset the value) the next value that is generated will be higher than the last one. It is usually just one high …
David Spillett's user avatar
12 votes
Accepted

MySQL - Autoincrement does not increment sequentally if last row was deleted

This is by design - all DBMS act this was with auto-increment columns. If they did not external referential integrity could be damaged. For a simple example of this, imagine you are storing URLs for …
David Spillett's user avatar
14 votes
Accepted

Why does auto increment jumps by more than the number of rows inserted?

This is not unusual and there are a couple of causes. Sometimes it is due to optimisations the query runner makes to reduce contention issues with the counter resource, improving efficiency when there …
David Spillett's user avatar