您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

关于mysql的MERGE存储引擎简单例子_MySQL

2025/6/12 16:35:21发布11次查看
bitscn.com
关于mysql的merge存储引擎简单例子
作用:可以将多个表结构相同的表 和合并到一个表中
版本支持:mysql5.1
如下例子:
假设有如下几个表:结构完全相同 article_0,article_1,article_2,article_3,
-- table article_0 ddlcreate table `article_0` ( `id` bigint(20) not null, `subject` varchar(200) not null, `content` text not null, primary key (`id`)) engine=myisam default charset=utf8;-- table article_1 ddlcreate table `article_1` ( `id` bigint(20) not null, `subject` varchar(200) not null, `content` text not null, primary key (`id`)) engine=myisam default charset=utf8;-- table article_2 ddlcreate table `article_2` ( `id` bigint(20) not null, `subject` varchar(200) not null, `content` text not null, primary key (`id`)) engine=myisam default charset=utf8;-- table article_3 ddlcreate table `article_3` ( `id` bigint(20) not null, `subject` varchar(200) not null, `content` text not null, primary key (`id`)) engine=myisam default charset=utf8;
建立总表:article_total 结构如下:
-- table article_total ddlcreate table `article_total` ( `id` bigint(20) not null, `subject` varchar(200) not null, `content` text not null, primary key (`id`)) engine=mrg_myisam default charset=utf8 union=(`article_0`,`article_1`,`article_2`,`article_3`);
那么 article_total 表的内容就包含了article_0`,`article_1`,`article_2`,`article_3`的内容
select * from article_total 表的结果就是各个表述数据合并的内容
修改合并哪些子表的命令:
alter table article_total union =(article_0,article_1,article_2,article_3)
bitscn.com
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product