小贝_mysql分区实例_MySQL

WBOY
Release: 2016-06-01 12:59:01
Original
1207 people have browsed it

mysql分区实验

简要:

一、按照分区类型建立分区

二、管理分区

三、分区与未分区表例子

一、建立分区以hash分区为例

(1)、非线性hash分区

1、测试表t_hash结构

create table t_hash

(id int unsigned,

name char(1)

)engine=myisam charset=utf8

partition by hash(id)

partitions 5;

2、t_hash表物理文件结构

\

3、往t_hash表插入数据

\

4、查看表t_hash物理结构

\

总结: hash分区是平均分布。因此每个分区的数据文件大小是相等的。

二、管理分区

1、针对hash分区

\

2、把分区数5调整为2

\

3、把分区数2调整为1

\

总结: 一旦进行hash分区,那么至少存在一个分区。

三、分区与未分区表例子

1、测试表

未分区表:

create table t2

(id int unsigned,

name char(1)

)engine=myisam charset=utf8;

分区表:

create table t1

(id int unsigned,

name char(1)

)engine=myisam charset=utf8

partition by hash(id)

partitions 4;


2、插入相同条数的数据

\

3、查找name为a的数据

\

(备注: 在没有添加索引的情况下,分区的所花费的时间比未分区的小)

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!