mysql存储引擎二 memory merge berkeleydb存储引擎
MEMORY存储引擎通过采用内存中的内容来创建表。每个Memory表实际上和一个磁盘文件关联起来,文件名采用”表名.frm”的格式。Memory类型的表访问速度极快,因为数据源来自内存,所以数据库关闭时,内存中的数据就会发生丢失。默认使用Hash索引。
<code class="hljs asciidoc">mysql> create table memory_table( id int primary key, name varchar(20) )engine=memory;
Query OK, 0 rows affected (0.02 sec)
mysql> insert into memory_table(id,name) values(2,'frank');
Query OK, 1 row affected (0.00 sec)
mysql> select * from memory_table;
+----+-----------+
| id | name |
+----+-----------+
| 1 | frankstar |
| 2 | frank |
+----+-----------+
2 rows in set (0.00 sec)
mysql> show table status like 'memory_table' \G;
*************************** 1. row ***************************
Name: memory_table
Engine: MEMORY
Version: 10
Row_format: Fixed
Rows: 2
Avg_row_length: 66
Data_length: 127008
Max_data_length: 12582900
Index_length: 126992
Data_free: 0
Auto_increment: NULL
Create_time: 2016-05-09 22:23:47
Update_time: NULL
Check_time: NULL
Collation: utf8_bin
Checksum: NULL
Create_options:
Comment:
1 row in set (0.00 sec)
ERROR:
No query specified
mysql> show index from memory_table \G;
*************************** 1. row ***************************
Table: memory_table
Non_unique: 0
Key_name: PRIMARY
Seq_in_index: 1
Column_name: id
Collation: NULL
Cardinality: 2
Sub_part: NULL
Packed: NULL
Null:
Index_type: HASH
Comment:
Index_comment:
1 row in set (0.00 sec)
ERROR:
No query specified
</code>
memory表的内存储存在内存中,如果表的数据很大,那么服务器将会自动将其转换为磁盘表,阀值由temp_table_size系统变量来确定。每个memory表的容量由max_heap_table_size变量的值控制。默认16MB。<br> 主要用于数据内容变化不频繁的代码表及访问速度要求较高、数据量不大的场合,同时需要考虑更新操作数据不回写入到磁盘文件中。
MERGE
它实际上是一组myisam表的组合,将一组结构相同的MyISAM表组合在一起,MERGE表本身没有数据,对于该类型表的插入操作,是通过INSERT_METHOD定义完成的,取值为LAST或者为FIRST,FIRST意味着数据增加到组合表中的第一个myisam表中,同理LAST意味着添加到最后一个表中。所以MERGE表的文件有2个,一个是.frm文件,用于存放数据,还有一个MRG文件,用于存放MERGE表的名称,包括其组成表。
如下:
<code class="hljs asciidoc"><code class="hljs haml">mysql> create table myisam_table1(
-> id int primary key,
-> data datetime
-> )engine=myisam;
Query OK, 0 rows affected (0.02 sec)
create table myisam_table2( id int primary key, data datetime )engine=myisam;
Query OK, 0 rows affected (0.01 sec)
mysql> create table table1_merge_table2(
-> id int primary key,
-> data datetime
-> )engine=merge union=(myisam_table1,myisam_table2) insert_method=first;
Query OK, 0 rows affected (0.01 sec)</code></code><code class="hljs haml">向2个字表分别添加数据,如下:
<code class="hljs asciidoc"><code class="hljs haml"><code class="hljs cs">mysql> insert into myisam_table1 values(1,'2016-5-7'); Query OK, 1 row affected (0.00 sec) mysql> insert into myisam_table1 values(2,'2016-5-6'); Query OK, 1 row affected (0.00 sec) mysql> insert into myisam_table2 values(1,'2016-5-7'); Query OK, 1 row affected (0.00 sec) mysql> insert into myisam_table2 values(2,'2016-5-6'); Query OK, 1 row affected (0.00 sec) </code></code></code>
<code class="hljs haml"><code class="hljs cs">查询merge表,如下:
微商城订单管理系统是一款基于php+mysql开发的php订单管理系统,她的特点如下: 产品特色: 支持商品规格、订单短信提醒,订单提交限制,站外调用, 批量发货/导出,数据报表,物流轨迹、免签支付等。 1、高度开源:除核心授权文件外全部开源,二开方便。 2、分布式部署:支持分布式部署、支持数据库读写分离。 3、第三方存储:支持附件腾讯云、阿里云、七牛云存储
22
<code class="hljs asciidoc"><code class="hljs haml"><code class="hljs cs"><code class="hljs asciidoc">mysql> select * from table1_merge_table2; +----+---------------------+ | id | data | +----+---------------------+ | 1 | 2016-05-07 00:00:00 | | 2 | 2016-05-06 00:00:00 | | 1 | 2016-05-07 00:00:00 | | 2 | 2016-05-06 00:00:00 | +----+---------------------+ 4 rows in set (0.01 sec)</code></code></code></code>
<code class="hljs haml"><code class="hljs cs"><code class="hljs asciidoc">向merge表中添加一条数据,如下:
<code class="hljs asciidoc"><code class="hljs haml"><code class="hljs cs"><code class="hljs asciidoc"><code class="hljs asciidoc">mysql> insert into table1_merge_table2 values(3,'2016-5-8'); Query OK, 1 row affected (0.00 sec) mysql> select * from table1_merge_table2; +----+---------------------+ | id | data | +----+---------------------+ | 1 | 2016-05-07 00:00:00 | | 2 | 2016-05-06 00:00:00 | | 3 | 2016-05-08 00:00:00 | | 1 | 2016-05-07 00:00:00 | | 2 | 2016-05-06 00:00:00 | +----+---------------------+ 5 rows in set (0.00 sec) mysql> select * from myisam_table1; +----+---------------------+ | id | data | +----+---------------------+ | 1 | 2016-05-07 00:00:00 | | 2 | 2016-05-06 00:00:00 | | 3 | 2016-05-08 00:00:00 | +----+---------------------+ 3 rows in set (0.00 sec) mysql> select * from myisam_table2; +----+---------------------+ | id | data | +----+---------------------+ | 1 | 2016-05-07 00:00:00 | | 2 | 2016-05-06 00:00:00 | +----+---------------------+ 2 rows in set (0.00 sec)</code></code></code></code></code>
<code class="hljs haml"><code class="hljs cs"><code class="hljs asciidoc"><code class="hljs asciidoc">INSERT_METHOD的指定起作用了,如果没有指定,那么当试图往Merge表中insert数据时,都会发生错误。通常使用merge表来透明的对多个表进行查询和更新。
<code class="hljs haml"><code class="hljs cs"><code class="hljs asciidoc"><code class="hljs asciidoc">BerkeleyDB存储引擎<code class="hljs haml"><code class="hljs cs"><code class="hljs asciidoc"><code class="hljs asciidoc">简称BDB,创建该类型的表时,会有2个数据文件,一个.frm文件存储表元数据,另一个.db文件存储数据和索引文件,类似innodb。它的实现事务安全有redo日志。在每次启动的时候,都会做一次检查操作,将所有的redo日志清空。它和Memory引擎一样,都是页级锁定。
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号