What sequences are, who supports them, and why they're better than GUIDs or auto-increment columns except when they aren't.
What sequences are
When I say "sequence" I actually mean "sequence generator" because that's what SQL's CREATE SEQUENCE statement actually creates. So a sequence is a black box that produces an integer with a guarantee that this integer is greater than the previous integer that it produced, and less than the next integer that it will produce. Thus if I invoke it five times I might get 2, 4, 5, 6, 7. In poker that wouldn't be considered a sequence because there's a gap between 2 and 4. We can make sequences with few gaps or no gaps, but they're expensive.
Sequences are good for generating unique keys, although they're not the only tool for that.
How they work
This is the minimal scenario with a good DBMS.
An administrator says "create sequence x", with most things default: …[Read more]