Page 1 of 1

How to set the primary?

Posted: Tue Oct 31, 2006 5:11 pm
by just_trying
What is the best way to index this table? I have somewhere around 100,000 rows mainly I want to be able to search by the usr_name txt fld

Normally, I just use my auto_increment field as my primary and index however, with this table I will never by selecting on the id just the usr_name. I read a post here talking about making the field that is searched on the primary I just wasn't sure if I was doing it right...Here is what I've tried:

Code: Select all

CREATE TABLE `test`.`tbl_test` (
  `id` int(11) NOT NULL auto_increment,
  `usr_name` text NOT NULL,
  `sent_flag` tinyint(1) NULL DEFAULT '0',
  PRIMARY KEY ( `usr_name`(1))
) ENGINE=MyISAM;
many thanks

Posted: Tue Oct 31, 2006 6:17 pm
by John Cartwright
Lose to (1) and it should work :wink: