(1)memory是基于内存数据的存储引擎
(2)一张memory表,在磁盘上有一个表定义文件(.frm),在内存中保存数据。
(3)特点:基于内存,所以访问速度特别快。
(4)默认使用Hash索引,也可以指定B树索引。
(5)注意:mysql服务关闭,则表的数据就会丢失。
(6)使用memory,要注意内存是否足够。对不用的memory表,要及时删除或truncate;
(7)每个memory表的大小受系统变量max_heap_table_size的约束,初始值为16MB
(8)可以在使用--init-file选项包含一个文件,在文件中写入诸如
insert into ...select 或者 load data infile 。
效果是在mysql服务启动时,从持久稳固的数据源中装载数据。
使用实例:
create table tab_memory engine=memory
select city_id,city
from city
group by city_id;
可以看到这样可以把一些对访问速度有特殊要求的数据加载到内存中去使用。
指定索引方式:
create index i_name
using btree
on t_table;
查看表的索引:
show index
from t_table \G
删除索引:
drop index
i_name
on t_table;