I understand that an index is used to "speed stuff up", but am foggy on the
details.  Eg, let's say I have an "authors" table with fname, mname, and
lname fields for first, middle and last names.  Plus an auto_increment
primary key.  I will want to sort on author last name for output of sorted
authors, and also want to prevent duplicate author names from being
inserted.  So, how would I set up an appropriate index, and then how would I
use it in the client code?

I assume I set up the index like so in the create table:
...
unique index (lname, fname, mname) ?

Do I give the index a name?  I notice this is optional in the syntax.
What's the reason to give/not give an index a name?

How do I tell my client code to "use the index" for sorting?

select lname, fname
from authors
order by ...?

Any advice for this newbie appreciated.

Thanks,
Chris




---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to