当前位置:网站首页>MySQL table partition creation method
MySQL table partition creation method
2022-07-01 06:48:00 【A small wave】
View table partition information
SELECT
partition_name part,
partition_expression expr,
partition_description descr,
table_rows
FROM
information_schema.PARTITIONS
WHERE
table_schema = SCHEMA ()
AND table_name = ' Table name ';
establish range Partition —— Partition field is integer
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 Partition Numeric field
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 Zoning quantity ;
# List Partition
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)
);
边栏推荐
- Introduction to spark (one article is enough)
- Common shortcut keys
- Rotate the animation component around the circle, take it and use it directly
- 华福证券开户是安全可靠的么?怎么开华福证券账户
- Using fuseki query when there are multiple models in TDB
- Summary of wechat official account embedded program to jump to wechat
- 图解事件坐标screenX、clientX、pageX, offsetX的区别
- Jena基于OWL的默认推理查询
- 产品学习(三)——需求列表
- K8S搭建Redis集群
猜你喜欢
随机推荐
NOC 设计的一些坑
H5 web page determines whether an app is installed. If it is installed, it will jump to the summary of the scheme to download if it is not installed
C language course set up salary management system (big homework)
node中引入模块的原理
给逆序对数求原数组
How to use Alibaba vector font files through CDN
产品学习(二)——竞品分析
If I am in Guangzhou, where can I open an account? Is it safe to open an account online?
数据库笔记
rclone常用子命令中文解释
Find the original array for the inverse logarithm
谷粒商城-环境(p1-p27)
下载外文期刊的方法
SQL statement
Product learning (III) - demand list
脏读、幻读和不可重复读
考研目录链接
为什么这么多人转行产品经理?产品经理发展前景如何?
How the esp32 deep sleep current is lower than 10uA
Chapitre V gestion des entrées / sorties








