索引的使用
 
索引太少返回结果很慢,但是索引太多,又会占用空间。每次插入新记录时,索引都会针对变化重新排序
 
什么时候使用索引
1.where 从句中用到的字段
 select * from tb where f1 = 'xx' ,如果f1 进行了索引,那么这条sql 语句的销毁就会提高
 
2 max(),min() 
 select max(id) from tb
 对id 索引非常有用,因为索引是按照顺序排序的,所以直接返回最后一个值即可
 
3.当返回的内容是索引的一部分时
 这种情况不必扫描全表,只需查看索引即可
这种情况是不行的:f1 char(20),index f1(10),select f1 from tb ,因为索引只有10个字符,返回的却是20个
字符,必须扫描全表,扫描索引是不行的
 
4.order by 
select * from tb order by f1,若  f1 是被索引的,则按照索引排序的顺序返回即可
 
5.在连接条件处使用
select t1.c1,t1.c2,t2.c3 
from t1 join t2 
on t1.c4=t2.c5
where t1.c6=xx;
如果 c4 和 c5 加了索引,也可以被使用到
 
6.不以% 开头的like 语句vs
select * from tb where name like 'jas%'
name 列加了索引也会被使用到
但是这种情况是不行的:select * from tb where name like '%jas%'
因为索引是按照第一个字符的字母顺序排序的
 
创建索引的一些建议:
1.where 条件中的字段创建索引
2.被索引的字段内容重复率越低越好,主键是最好的索引,每个id 只返回一条记录,枚举就比较差劲,比方
说 性别,查询 性别‘男’,可能会返回近一半的记录
3.使用前缀索引
4.不要创建太多的索引,太多的索引会拖慢插入和更新速度
 
最左原则
 
这个问题单纯的口头描述很难说清楚,直接看伪代码
 
create table tb (f1 char(20), f2 char(20), f3 char(20), f4 char(20), index(f1,f2,f3))
 
对于上面的表我们来进行下面几个sql 查询
 
1. select * from  tb where f1='xx1' and f2 ='xx2' and f3='xx3'
2. select * from  tb where f1='xx1' and f2 ='xx2' 
3. select * from  tb where f1='xx1' 
4. select * from  tb where f2 ='xx2' and f3='xx3'
5. select * from  tb where f1='xx1' and f3='xx3'
 
上面的sql 中 1,2,3 的索引全部其作用
4中索引不会起作用
5中只有索引f1 起作用
 
也就是说复合索引使用的时候,必须是从最左侧开始,且是连续的,这样所有的索引才会被使用到
 
explain
 
下面来说一个很有用的东西,explain
先来建两张表,存储学生和老师信息,
 
create table student
(
stu_id int(3) zerofill,
name char(10),
majar char(10),
teacher_id int
);
 
 
create table teacher
(
teacher_id int,
name char(10)
);
 
insert into student values
(1,'丽丽','chemistry',1),
(2,'丽娟','english',2),
(3,'芳丽','儒学',3),
(4,'光头强','佛学',1),
(5,'熊大','math',2),
(6,'熊二','地理',3),
(7,'陶峰','高分子',4),
(8,'波波','机电',1),
(9,'米老鼠','土木',2);
 
insert into teacher values
(1,'刘老师'),
(2,'王老师'),
(3,'李老师'),
(4,'柴老师');
 
赶紧来试试explain
MariaDB [jason]> explain select * from student where stu_id=1;
+------+-------------+---------+------+---------------+------+---------+------+------+-------------+
| id   | select_type | table   | type | possible_keys | key  | key_len | ref  | rows | Extra       |
+------+-------------+---------+------+---------------+------+---------+------+------+-------------+
|    1 | SIMPLE      | student | ALL  | NULL          | NULL | NULL    | NULL |    9 | Using where |
+------+-------------+---------+------+---------------+------+---------+------+------+-------------+
 
给stu_id 加上索引再来试一下
MariaDB [jason]> alter table student add index(stu_id);
Query OK, 0 rows affected (0.02 sec)
Records: 0  Duplicates: 0  Warnings: 0
 
MariaDB [jason]> explain select * from student where stu_id=1;
+------+-------------+---------+------+---------------+--------+---------+-------+------+-------+
| id   | select_type | table   | type | possible_keys | key    | key_len | ref   | rows | Extra |
+------+-------------+---------+------+---------------+--------+---------+-------+------+-------+
|    1 | SIMPLE      | student | ref  | stu_id        | stu_id | 5       | const |    1 |       |
+------+-------------+---------+------+---------------+--------+---------+-------+------+-------+
 
有木有发现不一样?下面我们来解释一下explain 各个字段含义
说实话,我对参考资料中的的解释有些困惑,我想先自己造几个例子看看
 
 
MariaDB [jason]> show indexes from student ;
+---------+------------+------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table   | Non_unique | Key_name   | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+---------+------------+------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| student |          1 | stu_id     |            1 | stu_id      | A         |           9 |     NULL | NULL   | YES  | BTREE      |         |               |
| student |          1 | teacher_id |            1 | teacher_id  | A         |           9 |     NULL | NULL   | YES  | BTREE      |         |               |
+---------+------------+------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
 
MariaDB [jason]> drop index stu_id on student;
 
MariaDB [jason]> alter table student add primary key(stu_id);
 
MariaDB [jason]> show indexes from teacher;
+---------+------------+------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table   | Non_unique | Key_name   | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+---------+------------+------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| teacher |          1 | teacher_id |            1 | teacher_id  | A         |           1 |     NULL | NULL   | YES  | BTREE      |         |               |
+---------+------------+------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
1 row in set (0.00 sec)
 
MariaDB [jason]> drop index teacher_id on teacher;
Query OK, 0 rows affected (0.00 sec)
Records: 0  Duplicates: 0  Warnings: 0
MariaDB [jason]> show indexes from teacher;
+---------+------------+------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table   | Non_unique | Key_name   | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+---------+------------+------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| teacher |          1 | teacher_id |            1 | teacher_id  | A         |           1 |     NULL | NULL   | YES  | BTREE      |         |               |
+---------+------------+------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
1 row in set (0.00 sec)
 
MariaDB [jason]> drop index teacher_id on teacher;
Query OK, 0 rows affected (0.00 sec)
Records: 0  Duplicates: 0  Warnings: 0
 
MariaDB [jason]> alter talbe teacher add primary key(teacher_id);
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'talbe teacher add primary key(teacher_id)' at line 1
MariaDB [jason]> alter table teacher add primary key(teacher_id);
 
我们先把student表中的stu_id 和tercher表中的teacher_id 变成了主键
example1:
MariaDB [jason]> explain select * from student where stu_id = 1;
+------+-------------+---------+-------+---------------+---------+---------+-------+------+-------+
| id   | select_type | table   | type  | possible_keys | key     | key_len | ref   | rows | Extra |
+------+-------------+---------+-------+---------------+---------+---------+-------+------+-------+
|    1 | SIMPLE      | student | const | PRIMARY       | PRIMARY | 4       | const |    1 |       |
+------+-------------+---------+-------+---------------+---------+---------+-------+------+-------+
example2:
MariaDB [jason]> explain select * from student where stu_id > 2;
+------+-------------+---------+-------+---------------+---------+---------+------+------+-------------+
| id   | select_type | table   | type  | possible_keys | key     | key_len | ref  | rows | Extra       |
+------+-------------+---------+-------+---------------+---------+---------+------+------+-------------+
|    1 | SIMPLE      | student | range | PRIMARY       | PRIMARY | 4       | NULL |    7 | Using where |
+------+-------------+---------+-------+---------------+---------+---------+------+------+-------------+
example3:
MariaDB [jason]> explain select * from student where teacher_id = 1;
+------+-------------+---------+------+---------------+------------+---------+-------+------+-------+
| id   | select_type | table   | type | possible_keys | key        | key_len | ref   | rows | Extra |
+------+-------------+---------+------+---------------+------------+---------+-------+------+-------+
|    1 | SIMPLE      | student | ref  | teacher_id    | teacher_id | 5       | const |    3 |       |
+------+-------------+---------+------+---------------+------------+---------+-------+------+-------+
example4:
MariaDB [jason]> explain select * from student where teacher_id>2;
+------+-------------+---------+-------+---------------+------------+---------+------+------+-----------------------+
| id   | select_type | table   | type  | possible_keys | key        | key_len | ref  | rows | Extra                 |
+------+-------------+---------+-------+---------------+------------+---------+------+------+-----------------------+
|    1 | SIMPLE      | student | range | teacher_id    | teacher_id | 5       | NULL |    3 | Using index condition |
+------+-------------+---------+-------+---------------+------------+---------+------+------+-----------------------+
example5:
ariaDB [jason]> explain select s.stu_id,s.name,s.majar,s.teacher_id,t.name
    -> from student s join teacher t
    -> on s.teacher_id = t.teacher_id;
+------+-------------+-------+------+---------------+------+---------+------+------+-------------------------------------------------+
| id   | select_type | table | type | possible_keys | key  | key_len | ref  | rows | Extra                                           |
+------+-------------+-------+------+---------------+------+---------+------+------+-------------------------------------------------+
|    1 | SIMPLE      | t     | ALL  | PRIMARY       | NULL | NULL    | NULL |    4 |                                                 |
|    1 | SIMPLE      | s     | ALL  | teacher_id    | NULL | NULL    | NULL |    9 | Using where; Using join buffer (flat, BNL join) |
+------+-------------+-------+------+---------------+------+---------+------+------+-------------------------------------------------+
example6:
MariaDB [jason]> explain select s.stu_id,s.name,s.majar,s.teacher_id,t.name
    -> from student s left join teacher t
    -> on s.teacher_id = t.teacher_id;
+------+-------------+-------+--------+---------------+---------+---------+--------------------+------+-------+
| id   | select_type | table | type   | possible_keys | key     | key_len | ref                | rows | Extra |
+------+-------------+-------+--------+---------------+---------+---------+--------------------+------+-------+
|    1 | SIMPLE      | s     | ALL    | NULL          | NULL    | NULL    | NULL               |    9 |       |
|    1 | SIMPLE      | t     | eq_ref | PRIMARY       | PRIMARY | 4       | jason.s.teacher_id |    1 |       |
+------+-------------+-------+--------+---------------+---------+---------+--------------------+------+-------+
example7:
MariaDB [jason]> explain select s.stu_id,s.name,s.majar,s.teacher_id,t.name
    -> from student s left join teacher t
    -> on s.teacher_id = t.teacher_id
    -> where t.name is not null;
+------+-------------+-------+------+---------------+------+---------+------+------+-------------------------------------------------+
| id   | select_type | table | type | possible_keys | key  | key_len | ref  | rows | Extra                                           |
+------+-------------+-------+------+---------------+------+---------+------+------+-------------------------------------------------+
|    1 | SIMPLE      | t     | ALL  | PRIMARY       | NULL | NULL    | NULL |    4 | Using where                                     |
|    1 | SIMPLE      | s     | ALL  | teacher_id    | NULL | NULL    | NULL |    9 | Using where; Using join buffer (flat, BNL join) |
+------+-------------+-------+------+---------------+------+---------+------+------+-------------------------------------------------+
example8:
MariaDB [jason]> explain select s.stu_id,s.name,s.majar,s.teacher_id,t.name
    -> from student s right join teacher t
    -> on s.teacher_id = t.teacher_id;
+------+-------------+-------+------+---------------+------------+---------+--------------------+------+-------+
| id   | select_type | table | type | possible_keys | key        | key_len | ref                | rows | Extra |
+------+-------------+-------+------+---------------+------------+---------+--------------------+------+-------+
|    1 | SIMPLE      | t     | ALL  | NULL          | NULL       | NULL    | NULL               |    4 |       |
|    1 | SIMPLE      | s     | ref  | teacher_id    | teacher_id | 4       | jason.t.teacher_id |    1 |       |
+------+-------------+-------+------+---------------+------------+---------+--------------------+------+-------+
 
我尝试过使用full outer join ,但是mysql 不支持外连接
 
example9:
MariaDB [jason]> explain select stu_id,teacher_id from student;
+------+-------------+---------+-------+---------------+------------+---------+------+------+-------------+
| id   | select_type | table   | type  | possible_keys | key        | key_len | ref  | rows | Extra       |
+------+-------------+---------+-------+---------------+------------+---------+------+------+-------------+
|    1 | SIMPLE      | student | index | NULL          | teacher_id | 4       | NULL |    9 | Using index |
+------+-------------+---------+-------+---------------+------------+---------+------+------+-------------+
 
example10:
MariaDB [jason]> explain select max(teacher_id) from student;
+------+-------------+-------+------+---------------+------+---------+------+------+------------------------------+
| id   | select_type | table | type | possible_keys | key  | key_len | ref  | rows | Extra                        |
+------+-------------+-------+------+---------------+------+---------+------+------+------------------------------+
|    1 | SIMPLE      | NULL  | NULL | NULL          | NULL | NULL    | NULL | NULL | Select tables optimized away |
+------+-------------+-------+------+---------------+------+---------+------+------+------------------------------+
 
example11:
MariaDB [jason]> explain select * from student order by teacher_id desc;
+------+-------------+---------+------+---------------+------+---------+------+------+----------------+
| id   | select_type | table   | type | possible_keys | key  | key_len | ref  | rows | Extra          |
+------+-------------+---------+------+---------------+------+---------+------+------+----------------+
|    1 | SIMPLE      | student | ALL  | NULL          | NULL | NULL    | NULL |    9 | Using filesort |
+------+-------------+---------+------+---------------+------+---------+------+------+----------------+
 
example12:
MariaDB [jason]> explain select * from  student force index(teacher_id) order by teacher_id desc;
+------+-------------+---------+-------+---------------+------------+---------+------+------+-------+
| id   | select_type | table   | type  | possible_keys | key        | key_len | ref  | rows | Extra |
+------+-------------+---------+-------+---------------+------------+---------+------+------+-------+
|    1 | SIMPLE      | student | index | NULL          | teacher_id | 4       | NULL |    9 |       |
+------+-------------+---------+-------+---------------+------------+---------+------+------+-------+
 
example13:
MariaDB [jason]> alter table student add index(name);
MariaDB [jason]> explain select * from student where name like '丽%';
+------+-------------+---------+-------+---------------+------+---------+------+------+-----------------------+
| id   | select_type | table   | type  | possible_keys | key  | key_len | ref  | rows | Extra                 |
+------+-------------+---------+-------+---------------+------+---------+------+------+-----------------------+
|    1 | SIMPLE      | student | range | name          | name | 41      | NULL |    2 | Using index condition |
+------+-------------+---------+-------+---------------+------+---------+------+------+-----------------------+
 
example14:
MariaDB [jason]> explain select * from student where teacher_id +5 < 7;
+------+-------------+---------+------+---------------+------+---------+------+------+-------------+
| id   | select_type | table   | type | possible_keys | key  | key_len | ref  | rows | Extra       |
+------+-------------+---------+------+---------------+------+---------+------+------+-------------+
|    1 | SIMPLE      | student | ALL  | NULL          | NULL | NULL    | NULL |    9 | Using where |
+------+-------------+---------+------+---------------+------+---------+------+------+-------------+
1 row in set (0.01 sec)
 
MariaDB [jason]> explain select * from student where teacher_id < 2;
+------+-------------+---------+-------+---------------+------------+---------+------+------+-----------------------+
| id   | select_type | table   | type  | possible_keys | key        | key_len | ref  | rows | Extra                 |
+------+-------------+---------+-------+---------------+------------+---------+------+------+-----------------------+
|    1 | SIMPLE      | student | range | teacher_id    | teacher_id | 4       | NULL |    3 | Using index condition |
+------+-------------+---------+-------+---------------+------------+---------+------+------+-----------------------+
1 row in set (0.00 sec)
 
example 15:
MariaDB [jason]> explain select s.stu_id,s.name,s.majar,s.teacher_id,t.name
    -> from student s left join teacher t
    -> on s.teacher_id = t.teacher_id
    -> where t.teacher_id is null;
+------+-------------+-------+--------+---------------+---------+---------+--------------------+------+-------------------------+
| id   | select_type | table | type   | possible_keys | key     | key_len | ref                | rows | Extra                   |
+------+-------------+-------+--------+---------------+---------+---------+--------------------+------+-------------------------+
|    1 | SIMPLE      | s     | ALL    | NULL          | NULL    | NULL    | NULL               |    9 |                         |
|    1 | SIMPLE      | t     | eq_ref | PRIMARY       | PRIMARY | 4       | jason.s.teacher_id |    1 | Using where; Not exists |
+------+-------------+-------+--------+---------------+---------+---------+--------------------+------+-------------------------+
2 rows in set (0.00 sec)
 
example 16:
MariaDB [jason]> explain select *
    -> from t2 left join t1 on t2.f2=t1.f1
    -> left join t3 on t3.f3=t2.f2
    -> left join t4 on t4.f4=t3.f3
    -> where t1.f1=1;
+------+-------------+-------+-------+---------------+---------+---------+-------+------+-------------+
| id   | select_type | table | type  | possible_keys | key     | key_len | ref   | rows | Extra       |
+------+-------------+-------+-------+---------------+---------+---------+-------+------+-------------+
|    1 | SIMPLE      | t2    | const | PRIMARY       | PRIMARY | 4       | const |    1 | Using index |
|    1 | SIMPLE      | t1    | const | PRIMARY       | PRIMARY | 4       | const |    1 | Using index |
|    1 | SIMPLE      | t3    | const | PRIMARY       | PRIMARY | 4       | const |    1 | Using index |
|    1 | SIMPLE      | t4    | const | PRIMARY       | PRIMARY | 4       | const |    1 | Using index |
+------+-------------+-------+-------+---------------+---------+---------+-------+------+-------------+
 
 
这里没有列出最左原则的例子,大家可以自己个儿试一下,
 
关于expalin 各列的解释可以看这里
 
analyze table
 
mysql 在执行时select 或join 时会使用索引的分布信息来决定表的关联顺序、或使用那个索引,
analyze table tablename 就可以分析并存储索引的分布信息,
 
MariaDB [jason]> analyze table student;
+---------------+---------+----------+----------+
| Table         | Op      | Msg_type | Msg_text |
+---------------+---------+----------+----------+
| jason.student | analyze | status   | OK       |
+---------------+---------+----------+----------+
 
可以通过 show index from tb_name 来查看索引的情况
MariaDB [jason]> show index from student;
+---------+------------+------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table   | Non_unique | Key_name   | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+---------+------------+------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| student |          0 | PRIMARY    |            1 | stu_id      | A         |          10 |     NULL | NULL   |      | BTREE      |         |               |
| student |          1 | teacher_id |            1 | teacher_id  | A         |          10 |     NULL | NULL   |      | BTREE      |         |               |
| student |          1 | name       |            1 | name        | A         |          10 |     NULL | NULL   | YES  | BTREE      |         |               |
+---------+------------+------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
 
各字段的解释看这里
 
重点解释一下Cardinality
1. 列值代表的是此列中存储的唯一值的个数(如果此列为primary key 则值为记录的行数)
2. 列值只是个估计值,并不准确。
3. 列值不会自动更新,需要通过Analyze table来更新一张表或者mysqlcheck -Aa来进行更新整个数据库。
4. 列值的大小影响Join时是否选用这个Index的判断。
5. 创建Index时,MyISAM的表Cardinality的值为null,InnoDB的表Cardinality的值大概为行数。
6. MyISAM与InnoDB对于Cardinality的计算方式不同。
 
optimize
 
如果对表进行了大量的删除和更新操作,那么表中就会留下缝隙,optimize table tb_name 可以将缝隙删除
将分割的记录连接在一起
MariaDB [jason]> optimize table student;
+---------------+----------+----------+-------------------------------------------------------------------+
| Table         | Op       | Msg_type | Msg_text                                                          |
+---------------+----------+----------+-------------------------------------------------------------------+
| jason.student | optimize | note     | Table does not support optimize, doing recreate + analyze instead |
| jason.student | optimize | status   | OK                                                                |
+---------------+----------+----------+-------------------------------------------------------------------+
什么鬼?原来是innodb 不支持optimize, 百度找到了方法
 
ALTER TABLE table.name ENGINE='InnoDB';
 
This will create a copy of the original table, and drop the original table, and replace to the original place.
Although this is safe, but I suggest you do backup and test first before doing this.
 
 
 
 
 
 
 
 
 
 

《一起学mysql》4的更多相关文章

  1. 《从零开始做一个MEAN全栈项目》(1)

    欢迎关注本人的微信公众号"前端小填填",专注前端技术的基础和项目开发的学习. 在本系列的开篇,我打算讲一下全栈项目开发的优势,以及MEAN项目各个模块的概览. 为什么选择全栈开发? ...

  2. 《从零开始做一个MEAN全栈项目》(2)

    欢迎关注本人的微信公众号"前端小填填",专注前端技术的基础和项目开发的学习.   上一节简单介绍了什么是MEAN全栈项目,这一节将简要介绍三个内容:(1)一个通用的MEAN项目的技 ...

  3. 《从零开始做一个MEAN全栈项目》(3)

    欢迎关注本人的微信公众号"前端小填填",专注前端技术的基础和项目开发的学习. 上一篇文章给大家讲了一下本项目的开发计划,这一章将会开始着手搭建一个MEAN项目.千里之行,始于足下, ...

  4. 《从零开始做一个MEAN全栈项目》(4)

    欢迎关注本人的微信公众号"前端小填填",专注前端技术的基础和项目开发的学习. 在上一篇中,我们讲了如何去构建第一个Express项目,总结起来就是使用两个核心工具,express和 ...

  5. 一个关于vue+mysql+express的全栈项目(一)

    最近学了mysql数据库,寻思着能不能构思一个小的全栈项目,思来想去,于是就有了下面的项目: 先上几张效果图吧       目前暂时前端只有这几个页面,后端开发方面,有登录,注册,完善用户信息,获取用 ...

  6. Vue、Nuxt服务端渲染,NodeJS全栈项目,面试小白的博客系统~~

    Holle,大家好,我是李白!! 一时兴起的开源项目,到这儿就告一段落了. 这是一个入门全栈之路的小项目,从设计.前端.后端.服务端,一路狂飙的学习,发量正在欣喜若狂~~ 接触过WordPress,H ...

  7. Vue、Node全栈项目~面向小白的博客系统~

    个人博客系统 前言 ❝ 代码质量问题轻点喷(去年才学的前端),有啥建议欢迎联系我,联系方式见最下方,感谢! 页面有啥bug也可以反馈给我,感谢! 这是一套包含前后端代码的个人博客系统,欢迎各位提出建议 ...

  8. SpringBoot 整合 Elastic Stack 最新版本(7.14.1)分布式日志解决方案,开源微服务全栈项目【有来商城】的日志落地实践

    一. 前言 日志对于一个程序的重要程度不用过多的言语修饰,本篇将以实战的方式讲述开源微服务全栈项目 有来商城 是如何整合当下主流日志解决方案 ELK +Filebeat . 话不多说,先看实现的效果图 ...

  9. 全栈项目|小书架|服务器端-NodeJS+Koa2实现首页图书列表接口

    通过上篇文章 全栈项目|小书架|微信小程序-首页水平轮播实现 我们实现了前端(小程序)效果图的展示,这篇文章来介绍服务器端的实现. 首页书籍信息 先来回顾一下首页书籍都有哪些信息: 从下面的图片可以看 ...

  10. 全栈项目|小书架|服务器开发-NodeJS 使用 JWT 实现登录认证

    通过这篇 全栈项目|小书架|服务器开发-JWT 详解 文章我们对JWT有了深入的了解,那么接下来介绍JWT如何在项目中使用. 安装 $ npm install jsonwebtoken 生成 Toke ...

随机推荐

  1. js函数只执行一次,函数重写,变量控制与闭包三种做法

    一.情景需求 调用后台接口需要附带token信息,那么在每个请求的头部添加token的做法就不太优雅了:一个网站请求100次,那就得写添加100次token,假设某天接口有所变动,改起来就十分麻烦了. ...

  2. 1+x 证书 Web 前端开发初级理论考试(试卷8 )

    Web前端开发初级模拟测试卷(三) 共55道题 总分:200分 形考总分:0分 一.单选题共30题,60分 1.实现向右的红色三角形,样式实现正确的是( ) A <div class=" ...

  3. LeetCode 706:设计哈希映射 Design HashMap

    题目: 不使用任何内建的哈希表库设计一个哈希映射 具体地说,你的设计应该包含以下的功能 put(key, value):向哈希映射中插入(键,值)的数值对.如果键对应的值已经存在,更新这个值. get ...

  4. pytorch_13-图像处理之skimage

    之前程序使用的是PIL(Python image library),今天遇到了另一种图像处理包--skimage. skimage即scikit-image,PIL和Pillow只提供最基础的数字图像 ...

  5. 17-REST framework-Request与Response

    1.Django REST framework提供的视图的主要作用 1.控制序列化器的执行(检验,保存,转换数据) 2.控制数据库查询的执行 Request与Response 1.Request RE ...

  6. 多线程通信的两种方式? (可重入锁ReentrantLock和Object)

    (一)Java中线程协作的最常见的两种方式: (1)利用Object的wait().notify()和notifyAll()方法及synchronized (2)使用Condition.Reentra ...

  7. vue发送ajx请求 axios

    一. 简介 1.vue本身不支持发送AJAX请求,需要使用vue-resource(vue1.0版本).axios(vue2.0版本)等插件实现 2.axios是一个基于Promise的HTTP请求客 ...

  8. Idea-搜索快捷键

    1.Ctrl+N按名字搜索类 相当于eclipse的ctrl+shift+R,输入类名可以定位到这个类文件,就像idea在其它的搜索部分的表现一样,搜索类名也能对你所要搜索的内容多个部分进行匹配,而且 ...

  9. SpringBoot中数据加密存储和获取后解密展示AttributeConverter的实现

    1. 需求: 数据库存入数据的时候要加密处理,不同的字段加密方式不同. 界面上展示的时候要解密处理,解密方式相同. 2. 实现方案一: 定义公共的加密解密方法,然后在对应的字段上重写他的getset方 ...

  10. 转 SSD论文解读

    版权声明:本文为博主原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明. 本文链接:https://blog.csdn.net/u010167269/article/det ...