当前位置:网站首页>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)
);
边栏推荐
- TIDB数据库特性总结
- 连续四年入选Gartner魔力象限,ManageEngine卓豪是如何做到的?
- [postgraduate entrance examination advanced mathematics Wu Zhongxiang +880 version for personal use] advanced mathematics Chapter II Basic Stage mind map
- Make: g++: command not found
- FPGA - clocking -02- clock wiring resources of internal structure of 7 Series FPGA
- [self use of advanced mathematics in postgraduate entrance examination] advanced mathematics Chapter 1 thinking map in basic stage
- 【ManageEngine卓豪 】助力世界顶尖音乐学院--茱莉亚学院,提升终端安全
- Small guide for rapid completion of mechanical arm (VI): stepping motor driver
- Although pycharm is marked with red in the run-time search path, it does not affect the execution of the program
- Geoffrey Hinton: my 50 years of in-depth study and Research on mental skills
猜你喜欢
![kotlin位运算的坑(bytes[i] and 0xff 报错)](/img/2c/de0608c29d8af558f6f8dab4eb7fd8.png)
kotlin位运算的坑(bytes[i] and 0xff 报错)

JDBC database operation

Essay learning record essay multi label Global

Linux closes the redis process SYSTEMd+

连续四年入选Gartner魔力象限,ManageEngine卓豪是如何做到的?

SystemVerilog learning-08-random constraints and thread control

Top 10 Free 3D modeling software for beginners in 2022

ArcServer密码重置(账号不可以重置)
![Pit of kotlin bit operation (bytes[i] and 0xff error)](/img/2c/de0608c29d8af558f6f8dab4eb7fd8.png)
Pit of kotlin bit operation (bytes[i] and 0xff error)

【文件系统】如何在ubi之上运行squashfs
随机推荐
jdbc-连接池
Treasure taking from underground palace (memory based deep search)
Pla ne colle pas sur le lit: 6 solutions simples
Movable mechanical wall clock
skywalking集成nacos动态配置
讓田頭村變甜頭村的特色農產品是仙景芋還是白菜
MySQL中 in 和 exists 的区别
扩散(多源广搜)
DEV XPO对比之UOW
1034 Head of a Gang
Cjc8988 Low Power Stereo codec with 2 stereo headphone drivers
3D打印机穿线:5种简单的解决方案
Distributed lock implementation
交换机配置软件具有的作用
Understanding of C manualresetevent class
Transformer le village de tiantou en un village de betteraves sucrières
Uniapp tree level selector
异常检测方法梳理,看这篇就够了!
让厦门灌口镇田头村变“甜头”村的特色农产品之一是
c# Xml帮助类