MySQL学习笔记-索引失效的情况
1. 表结构
CREATE TABLE `t` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`word` varchar(16) NOT NULL DEFAULT '',
`num` int unsigned NOT NULL DEFAULT '0',
`date` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `word` (`word`),
KEY `num` (`num`),
KEY `date` (`date`)
) ENGINE=InnoDB
2. 插入实验数据
delimiter;
create procedure test_data()
begin
declare i int;
set i=0;
while i<10000 do
insert into t(word,num,date) values(concat(char(97+(i div 1000)), char(97+(i % 1000 div 100)), char(97+(i % 100 div 10)), char(97+(i % 10))),i+1,"2020-02-23");
set i=i+1;
end while;
end;
delimiter;
call test_data();
update t set word='1000' where id=10
如下图所示&