上一节在表的操做的最后一点,提到了一个设置存储引擎python
那什么是存储引擎呢?存储引擎能用来干什么?mysql
这就是本小节所要研究的问题了sql
库就是建立了一个文件夹,在文件夹里存储的文件就叫表数据库
那根据生活常识应该知道,不一样的文件的格式是不同的app
文字的就是txt,视频的就是MP4,音乐的就是MP3... ...ide
那对于表来讲也应该有不一样的类型用以存储不一样的信息搜索引擎
那这个搜索引擎,就是表的类型code
有个语句能够帮助你知道有什么引擎orm
show engines \G
视频
mysql> show engines \G *************************** 1. row *************************** Engine: FEDERATED Support: NO Comment: Federated MySQL storage engine Transactions: NULL XA: NULL Savepoints: NULL *************************** 2. row *************************** Engine: MRG_MYISAM Support: YES Comment: Collection of identical MyISAM tables Transactions: NO XA: NO Savepoints: NO *************************** 3. row *************************** Engine: MyISAM Support: YES Comment: MyISAM storage engine Transactions: NO XA: NO Savepoints: NO *************************** 4. row *************************** Engine: BLACKHOLE Support: YES Comment: /dev/null storage engine (anything you write to it disappears) Transactions: NO XA: NO Savepoints: NO *************************** 5. row *************************** Engine: CSV Support: YES Comment: CSV storage engine Transactions: NO XA: NO Savepoints: NO *************************** 6. row *************************** Engine: MEMORY Support: YES Comment: Hash based, stored in memory, useful for temporary tables Transactions: NO XA: NO Savepoints: NO *************************** 7. row *************************** Engine: ARCHIVE Support: YES Comment: Archive storage engine Transactions: NO XA: NO Savepoints: NO *************************** 8. row *************************** Engine: InnoDB Support: DEFAULT Comment: Supports transactions, row-level locking, and foreign keys Transactions: YES XA: YES Savepoints: YES *************************** 9. row *************************** Engine: PERFORMANCE_SCHEMA Support: YES Comment: Performance Schema Transactions: NO XA: NO Savepoints: NO 9 rows in set (0.00 sec)
那如今就进行简单的介绍,只是了解!!!!!!
create table e1(id int) engine= innodb;
create table e2(id int) engine= memory;
create table e3(id int) engine= blackhole;
create table e4(id int) engine= myisam;
mysql> create table e1(id int) engine= innodb; Query OK, 0 rows affected (0.72 sec) mysql> mysql> create table e2(id int) engine= memory; Query OK, 0 rows affected (0.07 sec) mysql> mysql> create table e3(id int) engine= blackhole; Query OK, 0 rows affected (0.13 sec) mysql> mysql> create table e4(id int) engine= myisam; Query OK, 0 rows affected (0.14 sec) mysql> show tables; +-------------+ | Tables_in_e | +-------------+ | e1 | | e2 | | e3 | | e4 | +-------------+ 4 rows in set (0.00 sec)
建立了以后,咱们就去文件夹里找一下咱们刚才建立的文件
frm后缀的是表结构,ibd 就是 innodb的缩写,因此咱们就看出来不是一个表就对应一个文件,那只是你的意淫
e2的搜索引擎是memory,特色是存在内存里的,而不是硬盘,因此没有数据存储,只有表结构
e3的搜索引擎是blackhole,特色是放进去数据就没了,因此也不须要数据存储,只有表结构
e4的搜索引擎是myisam,特色是支持索引,因此除了表结构,数据之外,还多了个索引文件
仍是这句话,只是简单了解就行!
那如今就来试试每一个引擎下的表的特色
首先先给上面的表格赋值
insert into e1 values(1);
insert into e2 values(1);
insert into e3 values(1);
insert into e4 values(1);
只验证两个具备表明性的引擎:
mysql> select * from e1; +------+ | id | +------+ | 1 | +------+ 1 row in set (0.00 sec) mysql> mysql> select * from e2; +------+ | id | +------+ | 1 | +------+ 1 row in set (0.02 sec) mysql> mysql> select * from e3; Empty set (0.00 sec) mysql> mysql> select * from e4; +------+ | id | +------+ | 1 | +------+ 1 row in set (0.00 sec)
咱们能够看出来e3里面的数据不见了,因此是否是丢进去就没有了~
这是将数据放在内存中,也就是将内存清理后数据就不见了
那怎么办才是将内存进行清理呢?关掉服务再开启就ok了
C:\Users\Administrator>net stop mysql MySQL 服务正在中止. MySQL 服务已成功中止。 C:\Users\Administrator>net start mysql MySQL 服务正在启动 ... MySQL 服务已经启动成功。 C:\Users\Administrator>mysql Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.6.45 MySQL Community Server (GPL) Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> use e Database changed mysql> select * from e1; +------+ | id | +------+ | 1 | +------+ 1 row in set (0.08 sec) mysql> select * from e2; Empty set (0.03 sec) mysql> select * from e3; Empty set (0.03 sec) mysql> select * from e4; +------+ | id | +------+ | 1 | +------+ 1 row in set (0.03 sec)
因此说能够肯定memory引擎是将表存在内存的