Page 1 of 1

should the "id" column always be auto_increment?

Posted: Tue Feb 14, 2006 12:24 pm
by a94060
people usually leav ehte colum id auto incrementing, is this a smart idea? This also causes it to become the index rite?

Posted: Tue Feb 14, 2006 12:47 pm
by RobertGonzalez
I don't think autoincrementing creates an index automatically. Typically developers set the id field to autoincrement, primary key which does make the id an index.

Posted: Tue Feb 14, 2006 2:25 pm
by feyd
last I checked, auto-increment can only be set to work on primary keys. If you don't have one, you can't auto-increment.

Posted: Tue Feb 14, 2006 2:38 pm
by Christopher
You can also use "sequences" which is how most other databases do it. I think most of the major PHP database classes for MySQL provide a sequence abstraction.

Posted: Tue Feb 14, 2006 3:01 pm
by a94060
rite now i got the auto increment on the id and primary key on something else i think.