InnoDB + AUTO_INCREMENT questions.
am 25.04.2006 11:04:17 von Phil Latio
Newbie questions here...
Reading the MySQL manual regarding InnoDB databases, can someone confirm
that:
1. if the server is rebooted, AUTO_INCREMENT reverts back to 1?
2. what happens if the field is specified as or PRIMARY KEY or UNIQUE?
Cheers
Phil
Re: InnoDB + AUTO_INCREMENT questions.
am 25.04.2006 19:21:09 von Bill Karwin
Phil Latio wrote:
> Newbie questions here...
>
> Reading the MySQL manual regarding InnoDB databases, can someone confirm
> that:
> 1. if the server is rebooted, AUTO_INCREMENT reverts back to 1?
False. The next row inserted into a table with an AUTO_INCREMENT column
generates a new value, the next in the sequence higher than the last
value that was generated for that column. Note that this could leave
gaps, if you have deleted rows in the meantime.
The database remembers which value was last generated per table, even
after a reboot.
> 2. what happens if the field is specified as or PRIMARY KEY or UNIQUE?
No difference.
Note that AUTO_INCREMENT can be declared only for an indexed integer
column, of which columns with PRIMARY KEY or UNIQUE constraints are
examples.
Regards,
Bill K.