mysql索引的创建

mysql索引的创建

-- 索引的创建(创建表的时候同事添加索引)
create table index1(
id int primary key not null,
name varchar(32) not null,
age int not null,
intro varchar(200),
unique key (name), -- 唯一索引
fulltext index (intro),-- 全文索引
index (age), -- 普通索引
index (name,age) -- 联合索引、复合索引
)engine myisam charset utf8;

 

-- 创建完数据表之后,在添加索引
create table index2(
id int,
name varchar(32) not null,
age tinyint unsigned not null,
intro varchar(200) not null
)engine myisam charset utf8;

-- 添加索引
alter table index2 add primary key(id),
add unique key(name),
add index(age),
add fulltext index(intro),
add index(name,age);

posted @ 2016-02-19 22:13  bybelief  阅读(135)  评论(0编辑  收藏  举报