Mysql分表查询引擎Merge技术总结
2014-10-15 16:33
288 查看
首先说一下Merge这个关键字在Oracle中是怎么运用的,废话不多说,先上一个例子
在这里,我做一下简单的说明,这里用表t_agent_info表中查询出来的数据更新t_agent_tem2表,如果这个数据已经在该表中存在,则执行相应的update,如果不存在则执行insert。
接下来进入我这篇文章的主题,在Mysql中,Merge是一个分表引擎。同样,我先上一个例子
看一下查询结果,想必大家已经看出一些原因了。
MERGE INTO t_agent_tem2 s USING(SELECT * FROM t_agent_info) d ON(S.id=d.id) WHEN MATCHED THEN UPDATE SET s.info_source=1 DELETE WHERE s.status=1 WHEN NOT MATCHED THEN INSERT (s.id,s.organization_no,s.agent_name,s.info_source,s.status) VALUES (d.id,d.organization_no,d.agent_name,d.info_source,d.status);
在这里,我做一下简单的说明,这里用表t_agent_info表中查询出来的数据更新t_agent_tem2表,如果这个数据已经在该表中存在,则执行相应的update,如果不存在则执行insert。
接下来进入我这篇文章的主题,在Mysql中,Merge是一个分表引擎。同样,我先上一个例子
create table test_1(id int primary key auto_increment,name varchar(36),type int(2) not null default 1) engine = MyISAM charset=UTF8; create table test_2(id int primary key auto_increment,name varchar(36),type int(2) not null default 2) engine = MyISAM charset=UTF8; create table test_3(id int primary key auto_increment,name varchar(36),type int(2) not null default 3) engine = MyISAM charset=UTF8; create table test(id int primary key auto_increment,name varchar(36),type int(2) not null default 0) engine = MRG_MyISAM union =(test_1,test_2,test_3) insert_method last charset UTF8; insert into test_1(name) values('孙悟空'); insert into test_2(name) values('猪八戒'); insert into test_3(name) values('沙悟净'); insert into test(name) values('陈玄奘'); select * from test_1; select * from test_2; select * from test_3; select * from test;
看一下查询结果,想必大家已经看出一些原因了。
相关文章推荐
- NC57查询引擎技术经典知识点总结
- mysql里分表技术与查询
- mysql用merge引擎进行分表
- MySQL查询优化技术之使用索引
- MySQL分表实现上百万上千万记录分布存储的批量查询设计模式
- MySQL查询优化技术系列讲座之使用索引
- MySQL查询优化技术系列讲座之使用索引
- MySQL查询优化技术讲座
- mysql 技术总结
- MySQL查询优化技术系列讲座之使用索引(一)
- MySQL查询优化技术系列讲座之使用索引(二)
- php查询mysql总结和预处理
- MySQL查询优化技术讲座
- php mysql 查询乱码 解决方法 总结 乱码总结 php 乱码
- mysql菜鸟手迹11--mysql存储引擎之Merge
- Mysql 分页技术总结
- MySQL查询优化技术讲座
- [转]MySQL查询优化技术讲座
- MySQL分表实现上百万上千万记录分布存储的批量查询设计模式
- MySQL- 存储引擎 MERGE 的介绍