mysql分区表建表语句
1、按照日期范围分区
```sql CREATE TABLE student ( id INT, name VARCHAR(255), birthday DATE ) PARTITION BY RANGE (birthday) ( PARTITION p0 VALUES LESS THAN ('2017-01-01'), PARTITION p1 VALUES LESS THAN ('2017-02-01'), PARTITION p2 VALUES LESS THAN ('2017-03-01'), PARTITION p3 VALUES LESS THAN (MAXVALUE) ); ```
简单的mysql语句2、按照数值范围分区
```sql CREATE TABLE student ( id INT, name VARCHAR(255), score INT ) PARTITION BY RANGE (score) ( PARTITION p0 VALUES LESS THAN (60), PARTITION p1 VALUES LESS THAN (70), PARTITION p2 VALUES LESS THAN (80), PARTITION p3 VALUES LESS THAN (MAXVALUE) ); ```
3、按照列表分区
```sql CREATE TABLE student ( id INT, name VARCHAR(255), city VARCHAR(255) ) PARTITION BY LIST (city) ( PARTITION p0 VALUES IN ('Beijing', 'Shanghai'), PARTITION p1 VALUES IN ('Guangzhou', 'Shenzhen'), PARTITION p2 VALUES IN ('Hangzhou', 'Nanjing'), PARTITION p3 VALUES IN (MAXVALUE) ); ```
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论