当前位置:网站首页>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)
);
边栏推荐
- Idea easy to use plug-in summary!!!
- [wechat applet low code development] second, resolve the code composition of the applet in practice
- Dirty reading, unreal reading and unrepeatable reading
- Jena基于OWL的默认推理查询
- Promise
- (上)苹果有开源,但又怎样呢?
- 解决kaniko push镜像到harbor时报错(代理导致):unexpected status code 503 Service Unavailable
- 问题解决:OfficeException: failed to start and connect(一)
- PAT (Advanced Level) Practice 1057 Stack
- 问题:OfficeException: failed to start and connect(二)
猜你喜欢
随机推荐
【微信小程序低代码开发】二,在实操中化解小程序的代码组成
Figure out the difference between event coordinates screenx, clientx, pagex and offsetx
MySQL learning
Which securities company does qiniu school cooperate with? Is it safe to open an account?
第五章 輸入/輸出(I/O)管理
Embedded system
DSBridge
Resttemplate use
Product learning (I) - structure diagram
TDB中多个model情况下使用fuseki查询
Record an online interface slow query problem troubleshooting
谷粒商城-环境(p1-p27)
存储过程学习笔记
3. Disabling copy construction
Async and await
How to use SCI hub
转行做产品经理,如何挑选产品经理课程?
Camouflage request header Library: Anti useragent
Idea easy to use plug-in summary!!!
SQL learning notes nine connections 2








