设为首页 加入收藏

TOP

MySQL分区之分区概述
2014-11-24 07:14:00 来源: 作者: 【 】 浏览:1
Tags:MySQL 分区 概述

MySQL分区之分区概述
环境: www.2cto.com
[html]
mysql> select version();
+-----------+
| version() |
+-----------+
| 5.5.28 |
+-----------+
1 row in set (0.00 sec)
分区是一种表的设计模式
分区,分而治之,其重点在于高可用(管理),而附属价值才是性能的提高
而且:
对存储引擎层透明
对应用程序层透明
支持的分区类型:
对于表:
水平分区 → 同一表中不同行的记录分配到不同的物理文件
对于索引:
局部分区索引 → 一个分区既存放数据又存放索引
可以用下列命令查询当前 数据库是否启用了分区功能:
[sql]
mysql> show variables like '%partition%';
+-------------------+-------+
| Variable_name | Value |
+-------------------+-------+
| have_partitioning | YES |
+-------------------+-------+
1 row in set (0.00 sec)
MySQL分区类型:
● RANGE 分区
● LIST 分区
● HASH 分区
● KEY 分区
不论创建何种类型的分区,如果表存在主键或者唯一性索引时,分区列必须是唯一性索引的一个组成部分。
[sql]
mysql> create table t( col1 int not null,
-> col2 int not null,
-> col3 int not null,
-> col4 int not null,
-> unique key (col1,col2)
-> )
-> partition by hash(col3)
-> partitions 4;
ERROR 1503 (HY000): A PRIMARY KEY must include all columns in the table's partitioning function
mysql> create table t( col1 int not null,
-> col2 int not null,
-> col3 int not null,
-> col4 int not null,
-> unique key (col1,col2)
-> )
-> partition by hash(col2)
-> partitions 4;
Query OK, 0 rows affected (0.08 sec)
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇介绍几种sql*plus常用的命令 下一篇mysql分区管理-range分区

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·Redis 分布式锁全解 (2025-12-25 17:19:51)
·SpringBoot 整合 Red (2025-12-25 17:19:48)
·MongoDB 索引 - 菜鸟 (2025-12-25 17:19:45)
·What Is Linux (2025-12-25 16:57:17)
·Linux小白必备:超全 (2025-12-25 16:57:14)