索引-语法

 代码:

-- 查看索引
show index from emp;

-- name字段为姓名字段,该字段的值可能会重复,为该字段创建索引
create index idx_emp_name on emp(name);

-- entrydate字段为入职日期字段,是非空且唯一,为该字段创建唯一索引
create unique index idx_emp_entrydate on emp(entrydate);

-- 为age,job,salary三个字段创建联合索引
create index idx_emp_age_job_sal on emp(age,job,salary);

-- 为managerid建立合适的索引提高查询效率
create index idx_emp_maj on emp(managerid);

-- 删除idx_emp_maj索引
drop index idx_emp_maj on emp;
posted @ 2023-04-18 21:12  惊鸿宴远赴人间  阅读(21)  评论(0)    收藏  举报