David:
I believe you mentioned it in a previous thread, but I forget what kind of field NameMam is. It's important because you might be required to give that key part in your index a length.
Also, I'm assuming that this index is on a unique identifier field. If it's not, then just substitute the word "INDEX" where you see the word "UNIQUE" below.
Otherwise, here's the syntax I find myself using most often:
ALTER TABLE fammammals CREATE UNIQUE `NameForYourIndex` ( NameMam, IDMam );
If you want/need to assign a length to one or both key parts:
ALTER TABLE fammammals CREATE UNIQUE `NameForYourIndex` ( NameMam( WhateverLengthIsReasonable ), IDMam ( WhateverLengthIsReasonable ) );
Even if your NameMam field doesn't require a length on the index, you might want to add a limitation because it would result in a shorter index, which would save you some space.
Wes
On Jul 18, 2004, at 11:31 AM, David Blomstrom wrote:
I'm trying to create my first composite index and need some help.
The MySQL Manual at http://dev.mysql.com/doc/mysql/en/CREATE_INDEX.html offers these directions:
CREATE [UNIQUE|FULLTEXT|SPATIAL] INDEX index_name [index_type] ON tbl_name (index_col_name,...)
index_col_name: col_name [(length)] [ASC | DESC]
* * * * * * * * * *
So I'm trying to plug that into my situation. If my table is named fammammals, and I want to put a composite index on two fields named NameMam and IDMam, would it look something like this?:
CREATE [UNIQUE|FULLTEXT|SPATIAL] INDEX index_name [index_type] ON fammammals (index_NameMam,...)
index_col_name: IDMam [(length)] [ASC | DESC]
And can I just paste this code into phpMyAdmin, where it says, "Run SQL query/queries on database [MY DATABASE]"?
Thanks.
__________________________________ Do you Yahoo!? Vote for the stars of Yahoo!'s next ad campaign! http://advision.webevents.yahoo.com/yahoo/votelifeengine/
--
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]