As I discovered recently, thanks to another user on this list, there is at
least one situation where you WILL need to also create a KEY index on a
PRIMARY KEY column -
If you have a composite primary key such as (col1, col2) and you wish to
place a foreign key on col2, you will ALSO have to add a KEY on col2 to be
able to do so.
Cheers,
Matt.
-Original Message-
From: Eldon Ziegler [mailto:[EMAIL PROTECTED]
Sent: 11 April 2004 08:53
To: [EMAIL PROTECTED]
Subject: Re: Do I specify a primary key to be primary, unique and index ?
From the MySQL documentation:
* A PRIMARY KEY is a unique KEY where all key columns must be defined
as NOT NULL.
KEY is a synonym for INDEX. So, specifying PRIMARY KEY implies UNIQUE and
INDEX.. You don't have to specify them yourself.
At 01:11 am 4/11/2004, you wrote:
>I learned that there are three types of indexes (PRIMARY, UNIQUE, and
>INDEX).
>
>Now assuming I create a performance-critical PRIMARY key, will I better
have
>to specify UNIQUE and INDEX for this column also !? It should be obvious
>that a primary key is unique anyway, and an index as well, shouldnt it !?
>Please note, I am not after saving disk space here, performance is all I am
>after, and such a three-fold indexing exercise just seems redundant to me
in
>the best case scenario, or harmful even, am I right there !?
>
>
>
>--
>MySQL General Mailing List
>For list archives: http://lists.mysql.com/mysql
>To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]