mysql 索引创建,查看与删除


a.创建索引


 主键索引:


ALTER TABLE table_name ADD PRIMARY KEY (column_list)


 唯一索引:


ALTER TABLE table_name ADD UNIQUE (column_list)


CREATE UNIQUE INDEX index_name ON table_name (column_list)


 普通索引:


ALTER TABLE table_name ADD INDEX index_name (column_list)


CREATE INDEX index_name ON table_name (column_list)


b.查看索引


 show index from table_name;


c.删除索引


DROP INDEX index_name ON talbe_name

ALTER TABLE table_name DROP INDEX index_name

ALTER TABLE table_name DROP PRIMARY KEY


d.重建索引


REPAIR TABLE `table_name` QUICK;