For a simple example of mysql's MERGE storage engine, a simple example of mysql's MERGE storage engine can be used to MERGE multiple tables with the same structure into one table. The following example is supported: mysql5.1: suppose there are several tables with the same structure: article_0, article_1, article_2, article_3, -- Tablearticle_0D
For a simple example of mysql's MERGE storage engine, a simple example of mysql's MERGE storage engine can be used to MERGE multiple tables with the same structure into one table. The following example is supported: mysql5.1: suppose there are several tables with the same structure: article_0, article_1, article_2, article_3, -- Table article_0 D
A simple example of mysql's MERGE storage engine
A simple example of mysql's MERGE storage engine
Role: You can merge multiple tables with the same structure into one table.
Supported versions: mysql5.1
Example:
Assume that there are several tables with the same structure: article_0, article_1, article_2, article_3,
-- Table "article_0" DDL
Create table 'Article _ 0 '(
'Id' bigint (20) not null,
'Subobject' varchar (200) not null,
'Content' text not null,
Primary key ('id ')
) ENGINE = MyISAM default charset = utf8;
-- Table "article_1" DDL
Create table 'Article _ 1 '(
'Id' bigint (20) not null,
'Subobject' varchar (200) not null,
'Content' text not null,
Primary key ('id ')
) ENGINE = MyISAM default charset = utf8;
-- Table "article_2" DDL
Create table 'Article _ 2 '(
'Id' bigint (20) not null,
'Subobject' varchar (200) not null,
'Content' text not null,
Primary key ('id ')
) ENGINE = MyISAM default charset = utf8;
-- Table "article_3" DDL
Create table 'Article _ 3 '(
'Id' bigint (20) not null,
'Subobject' varchar (200) not null,
'Content' text not null,
Primary key ('id ')
) ENGINE = MyISAM default charset = utf8;
Create a summary table: the structure of article_total is as follows:
-- Table "article_total" DDL
Create table 'Article _ total '(
'Id' bigint (20) not null,
'Subobject' 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 ');
The content of the article_total table contains the content of article_0 ', 'Article _ 1', 'Article _ 2', and 'Article _ 3'.
The result of the select * from article_total table is the content of the data merging statements.
Command to modify which sub-tables to merge:
Alter table article_total union = (article_0, article_1, article_2, article_3)