MySQL索引

-- 创建一般索引
CREATE TABLE tb_stu_info
(
id INT NOT NULL,
name CHAR(45) DEFAULT NULL,
dept_id INT DEFAULT NULL,
age INT DEFAULT NULL,
height INT DEFAULT NULL,
INDEX(height)
);

-- 创建唯一索引
CREATE TABLE tb_stu_info2
(
id INT NOT NULL,
name CHAR(45) DEFAULT NULL,
dept_id INT DEFAULT NULL,
age INT DEFAULT NULL,
height INT DEFAULT NULL,
UNIQUE INDEX(height)
);

-- 查看索引
SHOW INDEX FROM tb_stu_info2;

-- 删除索引
DROP INDEX height
ON tb_stu_info;

  

原文地址:https://www.cnblogs.com/277223178dudu/p/11393802.html