How to set the primary?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
just_trying
Forum Newbie
Posts: 1
Joined: Tue Oct 31, 2006 4:57 pm

How to set the primary?

Post 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
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Lose to (1) and it should work :wink:
Post Reply