标签:
1、 添加PRIMARY KEY(主键索引)
1)Alter table table_name add primary key idx_talbe_name_column_name (column_name);
2)Alter table table_name add primary key idx_table_name_column_name (`column_name`);
3)Create primary key idx_table_name_column_name on table_name (column_name);
2、添加普通索引(Btree)
create index idx_table_name_column_name on table_name(column);
3、添加唯一索引(索引列的值必须是唯一,允许为空)
Create unique index uni_table_column_column_name on table_name(column_name);
4、 添加全文索引(FULLTEXT) 只针对MyISAM引擎
Create FULLTEXT index full_table_name_column_name on table_name(column_name);
5、添加多列索引(最左前缀)
Create index idx_table_name_column1_name_column2_name on table_name(column1_name, column2_name);
6、删除索引
Drop index idx_name on table_name;
Alter table table_name drop index idx_name;
7、查看索引
show index from table_name\G
标签:
原文地址:http://www.cnblogs.com/langdashu/p/5912704.html