On 24/03/2006 11:06 a.m., Eric Beversluis wrote:
Can someone illustrate the correct syntax for using auto_increment in
making a table? I've studied the manual and I'm not seeing how it comes
out.
EG:
CREATE TABLE Books (
bookID INT(5) PRIMARY KEY AUTO_INCREMENT...
THEN WHAT?
Thanks.
EB
Should be:
bookID INT(5) NOT NULL AUTO_INCREMENT PRIMARY KEY
Primary keys have to be NOT NULL, and "AUTO_INCREMENT" must appear
before "PRIMARY KEY"
AUTO_INCREMENT fields should normally be INT UNSIGNED as well since you
generally won't want to store a negative ID number, and this gives you
an extra byte.
-Simon
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]