CREATE TABLE IF NOT EXISTS `table1` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(50) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1; CREATE TABLE IF NOT EXISTS `table2` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(50) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1; INSERT INTO `table1` (`name`) VALUES('name1'); INSERT INTO `table2` (`name`) VALUES('name2'); CREATE TABLE IF NOT EXISTS `uTable` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(50) DEFAULT NULL, INDEX(id) ) ENGINE=MRG_MyISAM DEFAULT CHARSET=utf8 UNION=(table1,table2) INSERT_METHOD=LAST AUTO_INCREMENT=1; select id,name from uTable; INSERT INTO `uTable` (`name`) VALUES('name4');
Usage:
1. First build a part table: table1, and then build the operating table: uTable
2. table1 table data until certain conditions are met (or lot number of the larger space), rebuild a table Table2, reconstruction uTable table.
3. and so on.
Note: sub-table is only used to store data, do not directly operate, usually read only by inserting operation uTable query table can.