您好,欢迎访问一九零五行业门户网

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

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
其它类似信息

推荐信息