数据库建表建索引

CREATE TABLE `test1` (
   `id` INT (10) PRIMARY KEY NOT NULL AUTO_INCREMENT,
   `a` INT (10) NOT NULL,
   `b` INT (10) NOT NULL,
   `c` INT (10) NOT NULL,
    `d` INT (10) NOT NULL
) ;
INSERT INTO `test1`(`a`,`b`,`c`,`d`)VALUES(1,2,3,4),(2,3,5,1),(5,2,1,4),(1,4,2,3)
ALTER TABLE `test1` ADD INDEX idx_abcd(`a`,`b`,`c`,`d`)

如果是select xxxx from test1 where t4 order by t1,t2,t3
t1,t2,t3 的顺序是不变的,t4插入其中,如果不能成为索引的前缀,就会导致Extra:use filesort