当前位置:Gxlcms > 数据库问题 > mysql索引的创建

mysql索引的创建

时间:2021-07-01 10:21:17 帮助过:2人阅读

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);

mysql索引的创建

标签:

人气教程排行