Through pure SQL statements for creating a table, is it possible to make one with primary keys that auto-increment from 1
, and also reset themselves to the form 1, 2, ..., n
if one is deleted?
For example, if my table cool_dudes
has rows
id | name
------------------------
1 "John Skeet"
2 "Douglas Crockford"
3 "Steve Ballmer"
4 "Bjarne Stroustrup"
5 "Home Simpson"
and I delete Steve Ballmer, then it becomes
id | name
------------------------
1 "John Skeet"
2 "Douglas Crockford"
3 "Bjarne Stroustrup"
4 "Homer Simpson"
and any tables that have columns referencing cool_dudes.id
then those columns are updated accordingly.