33.mysql数据库学习

1.   utf8  utf8mb4

参考:http://www.javashuo.com/article/p-soxjxrqo-mz.htmlhtml

https://blog.csdn.net/weixin_42785557/article/details/83512138mysql

https://www.cnblogs.com/xingxia/p/database_mysql_character.htmlsql

 

应用:mysql索引

 

2. varchar   设置长度

 

 

3.mysql 引擎

这里战时只说: InnoDB和MyIsam测试

              https://blog.csdn.net/summerzbh123/article/details/81201839spa

      存储结构:.net

            相同点:都是B+Tree设计

         什么是B+Tree:   https://www.jianshu.com/p/486a514b0ded3d

         不一样点: htm

             由于: 存储的结构不一样  innoDB:是将数据与索引放在一块儿(聚合索引), MyIsam:数据与索引分开(非聚合索引

                        http://www.javashuo.com/article/p-uvjtmusv-be.html

            

             上面缘由致使:

            

 

      

 

 

4.索引

https://www.cnblogs.com/zuochuang/p/8184349.html

mysql索引类型和索引方法

 

4.1 索引类型

4.2 单索引 及联合索引

4.2.1 建立 sql语法


-- 单一索引
create index singoleindex on t_user (name) 


-- 联合索引
create index moreIndex on t_user (name,age,other) 

 

 

 

4.2.2 联合索引应用:


-- 单一索引
create index singoleindex on t_user (name) 


-- 联合索引
create index moreIndex on t_user (name,age,other) 

-- 1. key_len 为null 表示没有走索引
explain select * from t_user

-- 2.走索引了  33=10*3+2+1  10表示varchar长度  3:utf-8格式  2:非char类型占用  1:数据能够为null
explain select * from t_user where name ='张三'

--  3. 索引失效  缘由数据类型不对
explain select * from t_user where name =1

--  4. 索引位置不对   第一索引 没有被用索引其余索引失效
explain select * from t_user where age =15

-- 5.第一个索引不能少  跟顺序有关
explain select * from t_user where name ='张三' and age =15

-- 6. 跳过中间因此 也有效   Using index condition
explain select * from t_user where name ='张三' and other='学生'


-- 7。索引 设计的几个原则
-- 7.1 范围最后 原则

  explain select * from t_user where name ='张三' and age >=15
-- 7.2 最左边原则  2中的列子
-- 8.索引覆盖  
-- 8.1索引失效
explain select * from t_user
-- 索引覆盖 
  explain select t.name,t.age from t_user t
-- 9. like 查询索引状况
-- 9.1 索引失效 由于没有用头索引
explain select * from t_user where other like '%学生%'

-- 9.2  索引没有失效  可是like 字段并无生效
explain  select * from t_user where name ='张三' and other like '%学生%' 

-- 9.3 测试单索引的like   后%生效   其余不生效   除非发生索引覆盖
-- 索引失效
explain select * from t_user where other like '%学生%'
-- 索引可与使用
explain select * from t_user where other like '学生%'

 

(1) key_len 为null 表示没有走索引

(2)

(3) 

 

(4)

(5) 

 

 

(6)

 

(7)

(8)

(9)

咱们首先新建  单索引 以下:

 

 

4.3 Extra 的表明含义

https://www.cnblogs.com/wy123/p/7366486.html

 

 

 

4.4 key_len 计算

https://www.cnblogs.com/xuanzhi201111/p/4554769.html

相关文章
相关标签/搜索