mysql 的权限 和索引

MySQL中的权限分为三大类,如下:
Administrative privileges 用户此权限的用户能进行数据库管理的工作,不针对特别的数据库
Database privileges 针对具体的某个数据库以及数据库下所有的对象

Privileges for database objects 针对某个数据库对象,比如表、索引、视图、存储过程等


MySQL的Multiple-Column Index

MySQL can use multiple-column indexes for queries that test all the columns in the index, or queries that test just the first column, the first two columns, the first three columns, and so on


如果一个表有multiple-column索引,那么只有索引的最左前缀(leftmost prefix )才能被优化器使用。例如,有一个3列的索引在(col1, col2, col3),只有(col1), (col1, col2), 和 (col1, col2, col3) 才能走索引。

假如有以下表和索引的定义,索引testidx建立在col2列和col3列上:
db2 "create table test(col1 int, col2 int, col3 int)"
db2 "create index testidx on test(col2, col3)"

那么以下SQL会用到索引testidx:
SELECT * FROM test WHERE col2=1111"
SELECT * FROM test WHERE col2=1111 AND col3=2111"
SELECT * FROM test WHERE col2=1111 AND (col3=2111 OR col3=2112)"
SELECT * FROM test WHERE col2=1111 AND col3 >=2111 AND col3 < 2114"

以下SQL不会用到索引testidx:
"SELECT * FROM test WHERE col3=2111" 
"SELECT * FROM test WHERE col2=1111 OR col3=2111"

http://blog.csdn.net/qingsong3333/article/details/76736641

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值