描述
针对salaries表emp_no字段创建索引idx_emp_no,查询emp_no为10005,使用强制索引。
CREATE TABLE salaries
(
emp_no
int(11) NOT NULL,
salary
int(11) NOT NULL,
from_date
date NOT NULL,
to_date
date NOT NULL,
PRIMARY KEY (emp_no
,from_date
));
create index idx_emp_no on salaries(emp_no);
后台会检查是否使用强制索引
题目创建表是已经创建索引idx_emp_no了。所以我们只需要按题意使用强索引进行查询。
select *
from salaries
force index (idx_emp_no)
where emp_no=10005