? ? ? ?索引:是幫助DB高效獲取數(shù)據(jù)的數(shù)據(jù)結(jié)構(gòu)隙赁,有:B+tree杖狼、B-tree等,索引相當于一本書的目錄猿挚,關鍵字index咐旧。
(單列索引)唯一索引:就是索引的值必須唯一,關鍵字段:unique index
創(chuàng)建唯一索引:?alter table 表名 add unique index 索引名(列名);?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ?create unique index 索引名 on Table(列名);
例如:表:tbl_user 绩蜻、含有字段:user_name
for example: alter table tbl_user add?unique index username(user_name);
for example: create unique index username on tbl_user(user_name);
刪除唯一索引:alter table 表名 drop index 索引名铣墨;
? ? ? ? ? ? ? ? ? ? ? ? ? ? ?drop index 索引名 on 表名;
for example: alter table tbl_user drop index username;
for example: ?drop index username on tbl_user办绝;
多列索引:也叫復合索引伊约,例如:
create table test3 ( id int not null primary key auto_increment,
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? uname char(8) not null default '',
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? password char(12) not null,
? ? ? ? ? ? ? ? ? ? ? ? ? ? ?index(uname,password))type=myisam;