当前位置:网站首页>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)
);
边栏推荐
- [wechat applet] how to build a building block development?
- Spark入门(一篇就够了)
- Chapter V input / output (i/o) management
- [wechat applet low code development] second, resolve the code composition of the applet in practice
- (上)苹果有开源,但又怎样呢?
- Methods of downloading Foreign Periodicals
- 问题:OfficeException: failed to start and connect(三)
- 记一次线上接口慢查询问题排查
- 问题:OfficeException: failed to start and connect(二)
- 女生适合学产品经理吗?有什么优势?
猜你喜欢

Jena default inference query based on OWL

(上)苹果有开源,但又怎样呢?

Lxml module (data extraction)

产品学习(一)——结构图

How to use SCI hub

树莓派4的WiFi设置

C language course set up salary management system (big homework)

Product learning (II) - competitive product analysis

2022 年江苏省职业院校技能大赛(中职) 网络搭建与应用赛项公开赛卷

ESP32 ESP-IDF GPIO按键中断响应
随机推荐
Grain Mall - environment (p1-p27)
Free trial of self-developed software noisecreater1.1
图解事件坐标screenX、clientX、pageX, offsetX的区别
存储过程学习笔记
Gson的@JsonAdater注解的几种方式
3. Disabling copy construction
启牛学堂合作的证券公司是哪家?开户安全吗?
Which securities company does qiniu school cooperate with? Is it safe to open an account?
根据输入画有向图
Is it safe to buy funds on Alipay? Where can I buy funds
Find the original array for the inverse logarithm
MySQL learning
The code generator has eliminated the styling of xxxx js as it exceeds the max of 500kb
Esp32 esp-idf GPIO key interrupt response
Async and await
(I) apple has open source, but so what?
Camouflage request header Library: Anti useragent
ESP32 ESP-IDF ADC监测电池电压(带校正)
How to use Alibaba vector font files through CDN
2022 Jiangsu Vocational College skills competition (secondary vocational school) network construction and application open competition volume