µ±Ç°Î»Ö㺠´úÂëÃÔ >> MySQL >> mysqlĿ¼֮ΨһË÷Òý
  Ïêϸ½â¾ö·½°¸

mysqlĿ¼֮ΨһË÷Òý

Èȶȣº61   ·¢²¼Ê±¼ä£º2016-05-05 16:42:32.0
mysqlË÷Òý֮ΨһË÷Òý

¡¡¡¡mysql µÄΨһË÷ÒýÒ»°ãÓÃÓÚ²»Öظ´µÄ×ֶΣ¬Ò»°ã»á°Ñ±íÖеÄidÉèΪΨһË÷Òý£¬´´½¨Î¨Ò»Ë÷ÒýµÄÄ¿µÄ²»ÊÇΪÁËÌá¸ß²éѯËٶȣ¬¶øÊÇΪÁ˱ÜÃâÊý¾ÝÖظ´£¬×¢Ò⣺ΨһË÷Òý¿ÉÒÔÓжà¸ö£¬µ«ÊÇÁÐÖµ±ØÐëΨһ£¬´´½¨Î¨Ò»Ë÷ÒýʹÓùؼü×Öunique¡£

¡¡¡¡´´½¨Î¨Ò»Ë÷Òý

1£¬´´½¨±íµÄʱºò´´½¨Ë÷Òý£º

create table temp2(id int(10) not null auto_increment,title varchar(10) not null,cnt int(10) not null,primary key(`id`),index(`title`),unique key cnt(`cnt`)) engine=myisam;

 

2£¬Ìí¼ÓË÷Òý

¡¡¡¡

create unique index title on article(`title`);

3,

alter table article add index content(`content`);

 

Ö÷¼üË÷ÒýÊÇÌØÊâµÄΨһË÷Òý

  Ïà¹Ø½â¾ö·½°¸