索引-语法

 代码:

-- 查看索引
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 @   惊鸿宴远赴人间  阅读(15)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
点击右上角即可分享
微信分享提示