当前位置:网站首页>Mysql 表分区创建方法
Mysql 表分区创建方法
2022-07-01 06:14:00 【一个小浪吴啊】
查看表分区信息
SELECT
partition_name part,
partition_expression expr,
partition_description descr,
table_rows
FROM
information_schema.PARTITIONS
WHERE
table_schema = SCHEMA ()
AND table_name = '表名';
创建range分区 —— 分区字段为整型
DROP TABLE IF EXISTS `range_emp`;
CREATE TABLE `range_emp` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`empno` mediumint(8) unsigned NOT NULL DEFAULT '0',
`empname` varchar(20) NOT NULL DEFAULT '',
`job` varchar(9) NOT NULL DEFAULT '',
`mgr` mediumint(8) unsigned NOT NULL DEFAULT '0',
`hiredate` datetime NOT NULL,
`sal` decimal(7,2) NOT NULL,
`comn` decimal(7,2) NOT NULL,
`depno` mediumint(8) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6000001 DEFAULT CHARSET=utf8
PARTITION BY RANGE (id) (
PARTITION part0 VALUES LESS THAN (500000),
PARTITION part1 VALUES LESS THAN (1000000),
PARTITION part2 VALUES LESS THAN (1500000),
PARTITION part3 VALUES LESS THAN (2000000),
PARTITION part4 VALUES LESS THAN (2500000),
PARTITION part5 VALUES LESS THAN (3000000),
PARTITION part6 VALUES LESS THAN (3500000),
PARTITION part7 VALUES LESS THAN (4000000),
PARTITION part8 VALUES LESS THAN (4500000),
PARTITION part9 VALUES LESS THAN (5000000),
PARTITION part10 VALUES LESS THAN (5500000),
PARTITION part11 VALUES LESS THAN MAXVALUE);
hash分区 数字字段
DROP TABLE IF EXISTS `product_partiton_hash`;
CREATE TABLE `product_partiton_hash` (
`Id` int(11) NOT NULL AUTO_INCREMENT,
`ProductName` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`ProductId` int(11) NOT NULL,
PRIMARY KEY (`Id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4
PARTITION BY HASH (Id) PARTITIONS 分区数量 ;
# List分区
DROP TABLE IF EXISTS `product_partiton_list`;
CREATE TABLE `product_partiton_list` (
`Id` int(11) NOT NULL AUTO_INCREMENT,
`ProductName` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`ProductId` int(11) NOT NULL,
`ProductStatus` int(11) NOT NULL,
PRIMARY KEY (`Id`,`ProductStatus`) ,
INDEX `ProductId_index` (`ProductId`)
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4
PARTITION BY LIST(ProductStatus)(
PARTITION p0 VALUES in(0,1),
PARTITION p1 VALUES in(2,3,4)
);
边栏推荐
- [note] e-commerce order data analysis practice
- 1034 Head of a Gang
- 机械臂速成小指南(六):步进电机驱动器
- Tidb single machine simulation deployment production environment cluster (closed pit practice, personal test is effective)
- Understanding of C manualresetevent class
- SystemVerilog learning-09-interprocess synchronization, communication and virtual methods
- HDU - 1501 zipper (memory deep search)
- golang panic recover自定义异常处理
- highmap gejson数据格式转换脚本
- jdbc-连接池
猜你喜欢
![Pit of kotlin bit operation (bytes[i] and 0xff error)](/img/2c/de0608c29d8af558f6f8dab4eb7fd8.png)
Pit of kotlin bit operation (bytes[i] and 0xff error)

68 cesium code datasource loading czml

Understanding of C manualresetevent class

OpenGL es: (5) basic concepts of OpenGL, the process of OpenGL es generating pictures on the screen, and OpenGL pipeline

DHT11 temperature and humidity sensor

【网络安全工具】USB控制软件有什么用

JDBC database operation

IT服务管理(ITSM)在高等教育领域的应用
![kotlin位运算的坑(bytes[i] and 0xff 报错)](/img/2c/de0608c29d8af558f6f8dab4eb7fd8.png)
kotlin位运算的坑(bytes[i] and 0xff 报错)

ManageEngine卓豪助您符合ISO 20000标准(四)
随机推荐
DHT11 温湿度传感器
【网络安全工具】USB控制软件有什么用
B-树系列
DEV XPO对比之UOW
MongoDB:一、MongoDB是什么?MongoDB的优缺点
srpingboot security demo
ArcServer密码重置(账号不可以重置)
Dongle data collection
Using Baidu map to query national subway lines
PLA not pasted on the bed: 6 simple solutions
MySQL怎么存储emoji?
PLA不粘贴在床上:6个简单的解决方案
局域网监控软件有哪些功能
Fixed height of the first column in El table dynamic header rendering
FPGA - 7 Series FPGA internal structure clocking-01-clock Architecture Overview
地宫取宝(记忆化深搜)
Freeswitch dial the extension number
π disk, turning your computer into a personal private cloud
69 cesium code datasource loading geojson
69 Cesium代码datasource加载geojson