David A. Desrosiers wrote:
On Tue, 2007-11-27 at 21:57 +0200, Georgi Hristozov
wrote:
A little note - this will define the value from
which we continue
incrementing. So probably you will not want to set it to null. :) Use
n+1 (n=last user id) instead of that.
Incorrect. This will start incrementing at the next free, unused number
in the sequence. Try it yourself and see.
I've used this thousands of times with various CMS systems without a
single problem.
Yes, you're absolutely right. It seems that this trick with the zero is
a feature in MySQL, that I hadn't known before. :) By the way, it seems
that using "NULL" instead of "0" is a bit safer:
"NO_AUTO_VALUE_ON_ZERO affects handling of AUTO_INCREMENT columns.
Normally, you generate the next sequence number for the column by
inserting either NULL or 0 into it. NO_AUTO_VALUE_ON_ZERO suppresses
this behavior for 0 so that only NULL generates the next sequence number."
(from
http://dev.mysql.com/doc/refman/5.0/en/server-sql-mode.html )
--
Georgi Hristozov