`
liujiekasini0312
  • 浏览: 147133 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

MySQL数据库分表的3种方法

 
阅读更多
一,先说一下为什么要分表

当一张的数据达到几百万时,你查询一次所花的时间会变多,如果有联合查询的话,我想有可能会死在那儿了。分表的目的就在于此,减小数据库的负担,缩短查询时间。

根据个人经验,mysql执行一个sql的过程如下:
1,接收到sql;2,把sql放到排队队列中 ;3,执行sql;4,返回执行结果。在这个执行过程中最花时间在什么地方呢?第一,是排队等待的时间,第二,sql的执行时间。其实这二个是一回事,等待的同时,肯定有sql在执行。所以我们要缩短sql的执行时间。

mysql中有一种机制是表锁定和行锁定,为什么要出现这种机制,是为了保证数据的完整性,我举个例子来说吧,如果有二个sql都要修改同一张表的同一条数据,这个时候怎么办呢,是不是二个sql都可以同时修改这条数据呢?很显然mysql对这种情况的处理是,一种是表锁定(myisam存储引擎),一个是行锁定(innodb存储引擎)。表锁定表示你们都不能对这张表进行操作,必须等我对表操作完才行。行锁定也一样,别的sql必须等我对这条数据操作完了,才能对这条数据进行操作。如果数据太多,一次执行的时间太长,等待的时间就越长,这也是我们为什么要分表的原因。

二,分表

1,做mysql集群,例如:利用mysql cluster ,mysql proxy,mysql replication,drdb等等

有人会问mysql集群,根分表有什么关系吗?虽然它不是实际意义上的分表,但是它启到了分表的作用,做集群的意义是什么呢?为一个数据库减轻负担,说白了就是减少sql排队队列中的sql的数量,举个例子:有10个sql请求,如果放在一个数据库服务器的排队队列中,他要等很长时间,如果把这10个sql请求,分配到5个数据库服务器的排队队列中,一个数据库服务器的队列中只有2个,这样等待时间是不是大大的缩短了呢?这已经很明显了。所以我把它列到了分表的范围以内,我做过一些mysql的集群:

linux mysql proxy 的安装,配置,以及读写分离

mysql replication 互为主从的安装及配置,以及数据同步

优点:扩展性好,没有多个分表后的复杂操作(php代码)

缺点:单个表的数据量还是没有变,一次操作所花的时间还是那么多,硬件开销大。

2,预先估计会出现大数据量并且访问频繁的表,将其分为若干个表

这种预估大差不差的,论坛里面发表帖子的表,时间长了这张表肯定很大,几十万,几百万都有可能。 聊天室里面信息表,几十个人在一起一聊一个晚上,时间长了,这张表的数据肯定很大。像这样的情况很多。所以这种能预估出来的大数据量表,我们就事先分出个 N个表,这个N是多少,根据实际情况而定。以聊天信息表为例:

我事先建100个这样的表,message_00,message_01,message_02……….message_98,message_99.然后根据用户的ID来判断这个用户的聊天信息放到哪张表里面,你可以用hash的方式来获得,可以用求余的方式来获得,方法很多,各人想各人的吧。下面用hash的方法来获得表名:

查看复制打印?
<?php<wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">function get_hash_table($table,$userid) {</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">$str = crc32($userid);</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">if($str&lt;0){</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">$hash = "0".substr(abs($str), 0, 1);</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">}else{</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">$hash = substr($str, 0, 2);</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">}</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">return $table."_".$hash;</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">}</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">echo get_hash_table('message','user18991');</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">//结果为message_10</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">echo get_hash_table('message','user34523');</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">//结果为message_13</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">?&gt;</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">&lt;?php function get_hash_table($table,$userid) {</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">$str = crc32($userid);</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">if($str&lt;0){</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">$hash = "0".substr(abs($str), 0, 1);</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">}else{</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">$hash = substr($str, 0, 2);</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">}</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">return $table."_".$hash; }</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">echo get_hash_table('message','user18991');</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">//结果为message_10 echo get_hash_table('message','user34523');</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">//结果为message_13 ?&gt;</span><br style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">说明一下,上面的这个方法,告诉我们user18991这个用户的消息都记录在message_10这张表里,user34523这个用户的消息都记录在message_13这张表里,读取的时候,只要从各自的表中读取就行了。</span><br style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">优点:避免一张表出现几百万条数据,缩短了一条sql的执行时间</span><br style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">缺点:当一种规则确定时,打破这条规则会很麻烦,上面的例子中我用的hash算法是crc32,如果我现在不想用这个算法了,改用md5后,会使同一个用户的消息被存储到不同的表中,这样数据乱套了。扩展性很差。</span><br style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">3,利用merge存储引擎来实现分表</span><br style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">我觉得这种方法比较适合,那些没有事先考虑,而已经出现了得,数据查询慢的情况。这个时候如果要把已有的大数据量表分开比较痛苦,最痛苦的事就是改代码,因为程序里面的sql语句已经写好了,现在一张表要分成几十张表,甚至上百张表,这样sql 语句是不是要重写呢?举个例子,我很喜欢举子</span><br style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">mysql&gt;show engines;的时候你会发现mrg_myisam其实就是merge。</span><br style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">查看复制打印?</span><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">mysql&gt; CREATE TABLE IF NOT EXISTS `user1` (</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">-&gt;</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">`id` int(11) NOT NULL AUTO_INCREMENT,</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">-&gt;</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">`name` varchar(50) DEFAULT NULL,</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">-&gt;</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">`sex` int(1) NOT NULL DEFAULT '0',</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">-&gt;</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">PRIMARY KEY (`id`)</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">-&gt; ) ENGINE=MyISAM</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">Query OK, 0 rows affected (0.05 sec)</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">mysql&gt; CREATE TABLE IF NOT EXISTS `user2` (</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">-&gt;</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">`id` int(11) NOT NULL AUTO_INCREMENT,</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">-&gt;</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">`name` varchar(50) DEFAULT NULL,</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">-&gt;</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">`sex` int(1) NOT NULL DEFAULT '0',</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">-&gt;</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">PRIMARY KEY (`id`)</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">-&gt; ) ENGINE=MyISAM</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">Query OK, 0 rows affected (0.01 sec)</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">mysql&gt; INSERT INTO `user1` (`name`, `sex`) VALUES('张映', 0);</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">Query OK, 1 row affected (0.00 sec)</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">mysql&gt; INSERT INTO `user2` (`name`, `sex`) VALUES('tank', 1);</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">Query OK, 1 row affected (0.00 sec)</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">mysql&gt; CREATE TABLE IF NOT EXISTS `alluser` (</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">-&gt;</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">`id` int(11) NOT NULL AUTO_INCREMENT,</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">-&gt;</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">`name` varchar(50) DEFAULT NULL,</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">-&gt;</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">`sex` int(1) NOT NULL DEFAULT '0',</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">-&gt;</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">INDEX(id)</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">-&gt; ) TYPE=MERGE UNION=(user1,user2) INSERT_METHOD=LAST AUTO_INCREMENT=1 ;</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">Query OK, 0 rows affected, 1 warning (0.00 sec)</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">mysql&gt; select id,name,sex from alluser;</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">+----+--------+-----+</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">| id | name</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">| sex |</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">+----+--------+-----+</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">|</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">1 | 张映 |</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">0 |</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">|</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">1 | tank</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">|</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">1 |</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">+----+--------+-----+</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">2 rows in set (0.00 sec)</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">mysql&gt; INSERT INTO `alluser` (`name`, `sex`) VALUES('tank2', 0);</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">Query OK, 1 row affected (0.00 sec)</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">mysql&gt; select id,name,sex from user2</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">-&gt; ;</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">+----+-------+-----+</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">| id | name</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">| sex |</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">+----+-------+-----+</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">|</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">1 | tank</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">|</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">1 |</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">|</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">2 | tank2 |</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">0 |</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">+----+-------+-----+</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">2 rows in set (0.00 sec)</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><br style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">mysql&gt; CREATE TABLE IF NOT EXISTS `user1` (</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">-&gt;</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">`id` int(11) NOT NULL AUTO_INCREMENT,</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">-&gt;</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">`name` varchar(50) DEFAULT NULL,</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">-&gt;</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">`sex` int(1) NOT NULL DEFAULT '0',</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">-&gt;</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">PRIMARY KEY (`id`)</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">-&gt; ) ENGINE=MyISAM</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; Query OK, 0 rows affected (0.05 sec)</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">mysql&gt; CREATE TABLE IF NOT EXISTS `user2` (</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">-&gt;</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">`id` int(11) NOT NULL AUTO_INCREMENT,</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">-&gt;</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">`name` varchar(50) DEFAULT NULL,</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">-&gt;</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px">`sex` int(1) NOT NULL DEFAULT '0',</span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span style="font-family:simsun; font-size:14px; line-height:21px"></span><wbr style="font-family:simsun; font-size:14px; line-height:21px"><span></span></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
分享到:
评论

相关推荐

    zabbix 5.0 mysql 数据库分表操作详细流程

    其中有每个命令的使用说明与注释。并增加了清理数据的方式。以及导入输入的注意事项

    PHP操作mysql数据库分表的方法_.docx

    本文主要讨论如何使用PHP操作MySQL数据库进行分表。 分表是一种常见的数据库扩展策略,它通过将一个大表拆分成多个小表来提高查询效率和系统性能。在PHP中,我们可以编写SQL语句或者使用ORM(对象关系映射)框架来...

    PHP操作mysql数据库分表的方法.doc

    PHP操作mysql数据库分表的方法.doc

    MySQL数据库分表批量主键查询代理-mysql-partitions-proxy.zip

    "MySQL数据库分表批量主键查询代理-mysql-partitions-proxy"项目就是为了应对这一挑战而设计的。这个开源工具旨在优化数据库的查询效率,尤其在面对分表场景下的主键批量查询时,它能提供一个代理服务,有效地协调和...

    MySQL分表及分表后插入sql

    MySQL分表及分表后插入sql语句,表为订单表,可以参考一下

    MySQL 数据库分表分区.pdf

    日常开发中我们经常会遇到大表的情况,所谓的大表是指存储了百万级乃至千万级条记录的表。这样的表过于庞大,导致...分表和表分区的目的就是减少数据库的负担,提高数据库的效率,通常点来讲就是提高表的增删改查效率

    省市区镇MySQL数据库 分表 regions.sql

    最全最新中国省,市,地区 sql 数据。最新国标行政区规划最低到居委会这一级别了,行政区代码代码也变长了,不包含港澳台信息。

    PHP操作mysql数据库分表的方法

    标题中的“PHP操作mysql数据库分表的方法”是指在数据库设计中,当数据量过大时,为了提高查询效率和系统性能,通常会采用的一种优化策略——数据分片(Sharding)。这个过程涉及到如何将一个大的数据库表分成多个较...

    MySQL数据库之分库分表方案_ITPUB博客.mhtml

    MySQL数据库之分库分表方案_ITPUB博客.mhtml MySQL数据库之分库分表方案_ITPUB博客.mhtml MySQL数据库之分库分表方案_ITPUB博客.mhtml

    TP5+MySQL通用分表代码

    - 分表情况,2:日期分表,按照目标表里面的记录日期的字段,按照日期【日、周、月、年】拆分成多个表【本代码仅考虑unix时间戳来分表,其它不支持,您可以自己思考,自己修改代码】 - 注意,支持【子表】,填入...

    Python+MySQL分表分库实战

    3. **分布式数据库工具**:还有一些Python库如`shardingsphere`、`pyodbc`等,它们提供了分库分表的完整解决方案,包括路由规则定义、数据一致性保证、事务处理等,简化了数据库扩展的复杂度。 4. **性能优化**:在...

    MySQL数据库应用从入门到精通_第2版

    MySQL数据库是世界上最受欢迎的开源关系型数据库之一,广泛应用于各种规模的企业、网站和应用程序中。本书《MySQL数据库应用从入门到精通_第2版》旨在帮助读者从零基础开始,逐步掌握MySQL的使用技巧和高级功能,...

    php mysql分库分表实例

    "php mysql分库分表实例"这个主题就是针对这样的需求,它涉及到如何利用PHP编程语言来实现MySQL数据库的分库分表操作,以提高系统的性能和可扩展性。 分库分表是一种常见的数据库垂直切分和水平切分策略,用于解决...

    php实现mysql数据库分表分段备份

    标题中的“php实现mysql数据库分表分段备份”是指使用PHP编程语言来设计一个脚本,该脚本能够对MySQL数据库进行分表和分段备份。这种备份方式通常用于处理大数据量的数据库,以避免一次性备份整个数据库可能导致的...

    MYSQL数据库设计规范.docx

    可以通过历史数据归档或分库分表等方法来实现数据量的有效控制。 **5. 不在数据库中存储大二进制数据** - **级别**: 高危 - **原因**: 存储大量二进制数据会迅速增加数据库体积,并可能导致性能下降。通常这类...

    mysql分表创建

    MySQL作为一款广泛使用的开源关系型数据库,面对海量数据时,分表策略是一种有效的优化手段。本文将详细讲解如何在MySQL中进行分表创建,以及相关的源码和工具应用。 首先,分表(Sharding)是数据库水平扩展的一种...

    mysql高可用分库分表.pdf

    为了提升MySQL数据库的性能和可用性,常采用的策略是数据库分库分表,其中可以分为垂直分库、垂直分表、水平分库、水平分表等方法。 垂直分表是针对数据库表中的列进行拆分,将一张大表拆成若干个结构更小的表,以...

Global site tag (gtag.js) - Google Analytics