Score
0
Watch 44 Star 256 Fork 69

xuthus / 数据库SQL实战SQLMIT

Create your Gitee Account
Explore and code with more than 6 million developers,Free private repositories !:)
Sign up
Clone or download
39.针对上面的salaries表emp_no字段创建索引idx_emp_no.md 610 Bytes
Copy Edit Web IDE Raw Blame History
xuthus authored 2019-08-12 23:23 . add:all

针对上面的salaries表emp_no字段创建索引idx_emp_no

题目描述

针对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);

答案

select * from salaries indexed by idx_emp_no where emp_no = 10005;

题解

MySQL语法:

select * from salaries force index(idx_emp_no) where emp_no = 10005

Comment ( 0 )

Sign in for post a comment