List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:October 31 2001 10:28pm
Subject:Re: key question
View as plain text  
At 9:57 PM +0000 10/31/01, Federico Schwindt wrote:
>   i'm not sure if this belongs here, but i cannot seem to find the
>answer anywhere else.
>   first, what's the difference between:
>   PRIMARY KEY (key1, key2)

This creates an index within which pairs of key1/key2 values are unique.

>   PRIMARY KEY (key1), KEY (key2)

This creates an index within which key1 values are unique, and another
index (non-unique) on key2.

>   second, let's suppose the following table:
>   owner_id int(11),
>   customer_id int(11),
>   customer_info varchar(100)
>   and i want to search either by owner_id and customer_id.

Index them separately, then.

>   can i do this w/o creating the indexes by hand? or do i have to
>create'em explicity and specify which one i'm gonna use before
>performing a query?

MySQL won't create indexes for you.  You must specify that you want
them created.  However, during query execution, the MySQL optimizer normally
chooses the best index automatically.

>   if anyone can help me or point me to where i can find this kind of
>stuff i'd appreciate it.
>   thanks,
>   f.-

key questionFederico Schwindt31 Oct
  • Re: key questionPaul DuBois31 Oct
  • Re: key questionBill Adams31 Oct
RE: key questionRick Emery31 Oct
  • Re: key questionFederico Schwindt31 Oct
RE: key questionQuentin Bennett31 Oct
  • Re: key questionFederico Schwindt31 Oct
    • Re: key questionJeremy Zawodny1 Nov