首页 > 试题广场 >

Mysql中表user的建表语句如下, CREATE TAB

[单选题]
Mysql中表user的建表语句如下,
CREATE TABLE `user` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键Id',
  `name` varchar(255) DEFAULT NULL COMMENT '名称',
  `age` int(11) DEFAULT NULL COMMENT '年龄',
  `address` varchar(255) DEFAULT NULL COMMENT '地址',
  `created_time` datetime DEFAULT NULL COMMENT '创建时间',
  `updated_time` datetime DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`),
  KEY `idx_com1` (`name`,`age`,`address`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户表';
以下哪个查询语句没有使用到索引idx_com1?
  • select  *  from user where name=’张三’ and age = 25 and address=’北京大兴区’;
  • select  *  from user where name=’张三’ and address=’北京大兴区’;
  • select  *  from user where age = 25 and address=’北京大兴区’;
  • select  *  from user where address=’北京大兴区’  and age = 25 and name=’张三’
索引在使用的时候要遵守最左原则,这里的复合索引最左字段为name,在创建 `idx_com1` (`name`,`age`,`address`)索引的时候,实际上是创建了(name),(name,age),(name,age,address)三种索引,C选项里面没有关联到name字段,因此选择C
编辑于 2019-01-19 13:31:15 回复(0)