MySQL 存储引擎之Memory
• Memory存储引擎将所有数据存储在内存中以便加快对某些不重要数据的访
问速度
• 此存储引擎的使用范围已经变小,因为InnoDB已经提供了数据缓存区以便
对将经常访问的数据缓存在内存中
• 当MySQL重启时,Memory表中的数据会丢失,但表结构还在
• Memory只适用在只读表或者读操作占绝大多数的情况,因为对表的写操作
也会导致表锁,大大限制了并发性
• Memory表创建之后,在磁盘文件会生成一个相同表名的文件,后缀为.frm
,仅存储表结构而不存储表数据
[ ~]# mysql -u root -p mysql> CREATE TABLE test(id int,name varchar(10)) ENGINE=MEMORY; Query OK, 0 rows affected (0.11 sec) mysql> insert into test values(1,‘a‘); Query OK, 1 row affected (0.01 sec) mysql> insert into test values(2,‘b‘); Query OK, 1 row affected (0.01 sec) mysql> select * from temp; Empty set (0.01 sec) mysql> select * from test; +------+------+ | id | name | +------+------+ | 1 | a | | 2 | b | +------+------+ 2 rows in set (0.01 sec) mysql> exit; Bye
[ ~]# /etc/init.d/mysql.server restart Shutting down MySQL.... SUCCESS! Starting MySQL.. SUCCESS! [-master ~]# mysql -u root -p mysql> use course; Database changed mysql> select * from test; Empty set (0.00 sec) mysql> desc test; +-------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+-------------+------+-----+---------+-------+ | id | int(11) | YES | | NULL | | | name | varchar(10) | YES | | NULL | | +-------+-------------+------+-----+---------+-------+ 2 rows in set (0.01 sec)
相关推荐
云中舞步 2020-09-11
CoderToy 2020-11-16
emmm00 2020-11-17
王艺强 2020-11-17
ribavnu 2020-11-16
bianruifeng 2020-11-16
wangshuangbao 2020-11-13
苏康申 2020-11-13
vivenwan 2020-11-13
moyekongling 2020-11-13
云中舞步 2020-11-12
要啥自行车一把梭 2020-11-12
aydh 2020-11-12
kuwoyinlehe 2020-11-12
minerk 2020-11-12
vitasfly 2020-11-12
jazywoo在路上 2020-11-11
敏敏张 2020-11-11