At 9:57 PM +0000 10/31/01, Federico Schwindt wrote:
>hi,
>
> 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.-