Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.
Moderator: General Moderators
a94060
Forum Regular
Posts: 543 Joined: Fri Feb 10, 2006 4:53 pm
Post
by a94060 » Tue Feb 14, 2006 12:24 pm
people usually leav ehte colum id auto incrementing, is this a smart idea? This also causes it to become the index rite?
RobertGonzalez
Site Administrator
Posts: 14293 Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA
Post
by RobertGonzalez » Tue Feb 14, 2006 12:47 pm
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.
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Tue Feb 14, 2006 2:25 pm
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.
Christopher
Site Administrator
Posts: 13596 Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US
Post
by Christopher » Tue Feb 14, 2006 2:38 pm
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.
(#10850)
a94060
Forum Regular
Posts: 543 Joined: Fri Feb 10, 2006 4:53 pm
Post
by a94060 » Tue Feb 14, 2006 3:01 pm
rite now i got the auto increment on the id and primary key on something else i think.