日期:2014-05-16  浏览次数:20706 次

MYSQL Merge和分区

MYSQL Merge和分区 ?

?

mysql分表的方法

?

CREATE TABLE IF NOT EXISTS `user1` (  
   `id` int(11) NOT NULL AUTO_INCREMENT,  
   `name` varchar(50) DEFAULT NULL,  
  `sex` int(1) NOT NULL DEFAULT '0',  
  PRIMARY KEY (`id`)  
 ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; 


 CREATE TABLE IF NOT EXISTS `user2` (  
   `id` int(11) NOT NULL AUTO_INCREMENT,  
   `name` varchar(50) DEFAULT NULL,  
   `sex` int(1) NOT NULL DEFAULT '0',  
   PRIMARY KEY (`id`)  
 ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; 



 INSERT INTO `user1` (`name`, `sex`) VALUES('张映', 0); 

 INSERT INTO `user2` (`name`, `sex`) VALUES('tank', 1);


CREATE TABLE `alluser` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(50) DEFAULT NULL,
  `sex` int(1) NOT NULL DEFAULT '0',
  KEY `id` (`id`)
) ENGINE=MRG_MyISAM DEFAULT CHARSET=utf8 INSERT_METHOD=LAST UNION=(`user1`,`user2`);

?

?

?