上一節在表的操做的最後一點,提到了一個設置存儲引擎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引擎是將表存在內存的