1
create table t1 (a timestamp not null, primary key(a)) engine='InnoDB'
3
partition pa1 max_rows=20 min_rows=2,
4
partition pa2 max_rows=30 min_rows=3,
5
partition pa3 max_rows=30 min_rows=4,
6
partition pa4 max_rows=40 min_rows=2);
10
`a` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
12
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) (PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = InnoDB, PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = InnoDB, PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = InnoDB, PARTITION pa4 MAX_ROWS = 40 MIN_ROWS = 2 ENGINE = InnoDB) */
13
insert into t1 values ('1975-01-01 21:21:21'), ('2020-12-31 12:10:30'), ('1980-10-14 03:03'), ('2000-06-15 23:59');
20
select * from t1 where a=19801014030300;
23
delete from t1 where a=19801014030300;
30
create table t2 (a timestamp not null, primary key(a)) engine='InnoDB'
31
partition by key (a) partitions 12;
34
t2 CREATE TABLE `t2` (
35
`a` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
37
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) PARTITIONS 12 */
38
insert into t2 values ('1975-01-01 0:1:1'), ('2020-12-31 10:11:12'), ('1980-10-14 13:14:15'), ('2000-06-15 14:15:16');
45
select * from t2 where a='1980-10-14 13:14:15';
48
delete from t2 where a='1980-10-14 13:14:15';
56
insert into t2 values (19710101000000+59);
57
insert into t2 values (19710101000000+58);
58
insert into t2 values (19710101000000+57);
59
insert into t2 values (19710101000000+56);
60
insert into t2 values (19710101000000+55);
61
insert into t2 values (19710101000000+54);
62
insert into t2 values (19710101000000+53);
63
insert into t2 values (19710101000000+52);
64
insert into t2 values (19710101000000+51);
65
insert into t2 values (19710101000000+50);
66
insert into t2 values (19710101000000+49);
67
insert into t2 values (19710101000000+48);
68
insert into t2 values (19710101000000+47);
69
insert into t2 values (19710101000000+46);
70
insert into t2 values (19710101000000+45);
71
insert into t2 values (19710101000000+44);
72
insert into t2 values (19710101000000+43);
73
insert into t2 values (19710101000000+42);
74
insert into t2 values (19710101000000+41);
75
insert into t2 values (19710101000000+40);
76
insert into t2 values (19710101000000+39);
77
insert into t2 values (19710101000000+38);
78
insert into t2 values (19710101000000+37);
79
insert into t2 values (19710101000000+36);
80
insert into t2 values (19710101000000+35);
81
insert into t2 values (19710101000000+34);
82
insert into t2 values (19710101000000+33);
83
insert into t2 values (19710101000000+32);
84
insert into t2 values (19710101000000+31);
85
insert into t2 values (19710101000000+30);
86
insert into t2 values (19710101000000+29);
87
insert into t2 values (19710101000000+28);
88
insert into t2 values (19710101000000+27);
89
insert into t2 values (19710101000000+26);
90
insert into t2 values (19710101000000+25);
91
insert into t2 values (19710101000000+24);
92
insert into t2 values (19710101000000+23);
93
insert into t2 values (19710101000000+22);
94
insert into t2 values (19710101000000+21);
95
insert into t2 values (19710101000000+20);
96
insert into t2 values (19710101000000+19);
97
insert into t2 values (19710101000000+18);
98
insert into t2 values (19710101000000+17);
99
insert into t2 values (19710101000000+16);
100
insert into t2 values (19710101000000+15);
101
insert into t2 values (19710101000000+14);
102
insert into t2 values (19710101000000+13);
103
insert into t2 values (19710101000000+12);
104
insert into t2 values (19710101000000+11);
105
insert into t2 values (19710101000000+10);
106
insert into t2 values (19710101000000+9);
107
insert into t2 values (19710101000000+8);
108
insert into t2 values (19710101000000+7);
109
insert into t2 values (19710101000000+6);
110
insert into t2 values (19710101000000+5);
111
insert into t2 values (19710101000000+4);
112
insert into t2 values (19710101000000+3);
113
insert into t2 values (19710101000000+2);
114
insert into t2 values (19710101000000+1);
115
select count(*) from t2;
180
create table t3 (a timestamp not null, primary key(a)) engine='InnoDB'
181
partition by range (month(a)) subpartition by key (a)
183
partition quarter1 values less than (4),
184
partition quarter2 values less than (7),
185
partition quarter3 values less than (10),
186
partition quarter4 values less than (13)
188
show create table t3;
190
t3 CREATE TABLE `t3` (
191
`a` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
193
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (month(a)) SUBPARTITION BY KEY (a) SUBPARTITIONS 3 (PARTITION quarter1 VALUES LESS THAN (4) ENGINE = InnoDB, PARTITION quarter2 VALUES LESS THAN (7) ENGINE = InnoDB, PARTITION quarter3 VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION quarter4 VALUES LESS THAN (13) ENGINE = InnoDB) */
195
insert into t3 values (date_add('1970-01-01 00:00:00',interval 12-1 month));
196
insert into t3 values (date_add('1970-01-01 00:00:00',interval 11-1 month));
197
insert into t3 values (date_add('1970-01-01 00:00:00',interval 10-1 month));
198
insert into t3 values (date_add('1970-01-01 00:00:00',interval 9-1 month));
199
insert into t3 values (date_add('1970-01-01 00:00:00',interval 8-1 month));
200
insert into t3 values (date_add('1970-01-01 00:00:00',interval 7-1 month));
201
insert into t3 values (date_add('1970-01-01 00:00:00',interval 6-1 month));
202
insert into t3 values (date_add('1970-01-01 00:00:00',interval 5-1 month));
203
insert into t3 values (date_add('1970-01-01 00:00:00',interval 4-1 month));
204
insert into t3 values (date_add('1970-01-01 00:00:00',interval 3-1 month));
205
insert into t3 values (date_add('1970-01-01 00:00:00',interval 2-1 month));
206
insert into t3 values (date_add('1970-01-01 00:00:00',interval 1-1 month));
208
Warning 1264 Out of range value for column 'a' at row 1
209
select count(*) from t3;
227
create table t4 (a timestamp not null, primary key(a)) engine='InnoDB'
228
partition by list (month(a)) subpartition by key (a)
230
partition quarter1 values in (0,1,2,3),
231
partition quarter2 values in (4,5,6),
232
partition quarter3 values in (7,8,9),
233
partition quarter4 values in (10,11,12)
235
show create table t4;
237
t4 CREATE TABLE `t4` (
238
`a` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
240
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (month(a)) SUBPARTITION BY KEY (a) SUBPARTITIONS 3 (PARTITION quarter1 VALUES IN (0,1,2,3) ENGINE = InnoDB, PARTITION quarter2 VALUES IN (4,5,6) ENGINE = InnoDB, PARTITION quarter3 VALUES IN (7,8,9) ENGINE = InnoDB, PARTITION quarter4 VALUES IN (10,11,12) ENGINE = InnoDB) */
242
insert into t4 values (date_add('1970-01-01 00:00:00',interval 12-1 month));
243
insert into t4 values (date_add('1970-01-01 00:00:00',interval 11-1 month));
244
insert into t4 values (date_add('1970-01-01 00:00:00',interval 10-1 month));
245
insert into t4 values (date_add('1970-01-01 00:00:00',interval 9-1 month));
246
insert into t4 values (date_add('1970-01-01 00:00:00',interval 8-1 month));
247
insert into t4 values (date_add('1970-01-01 00:00:00',interval 7-1 month));
248
insert into t4 values (date_add('1970-01-01 00:00:00',interval 6-1 month));
249
insert into t4 values (date_add('1970-01-01 00:00:00',interval 5-1 month));
250
insert into t4 values (date_add('1970-01-01 00:00:00',interval 4-1 month));
251
insert into t4 values (date_add('1970-01-01 00:00:00',interval 3-1 month));
252
insert into t4 values (date_add('1970-01-01 00:00:00',interval 2-1 month));
253
insert into t4 values (date_add('1970-01-01 00:00:00',interval 1-1 month));
255
Warning 1264 Out of range value for column 'a' at row 1
256
select count(*) from t4;
274
create table t1 (a date not null, primary key(a)) engine='InnoDB'
275
partition by key (a) (
276
partition pa1 max_rows=20 min_rows=2,
277
partition pa2 max_rows=30 min_rows=3,
278
partition pa3 max_rows=30 min_rows=4,
279
partition pa4 max_rows=40 min_rows=2);
280
show create table t1;
282
t1 CREATE TABLE `t1` (
285
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) (PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = InnoDB, PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = InnoDB, PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = InnoDB, PARTITION pa4 MAX_ROWS = 40 MIN_ROWS = 2 ENGINE = InnoDB) */
286
insert into t1 values ('1975-01-01'), ('2020-12-31'), ('1980-10-14'), ('2000-06-15');
293
select * from t1 where a=19801014;
296
delete from t1 where a=19801014;
303
create table t2 (a date not null, primary key(a)) engine='InnoDB'
304
partition by key (a) partitions 12;
305
show create table t2;
307
t2 CREATE TABLE `t2` (
310
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) PARTITIONS 12 */
311
insert into t2 values ('1975-01-01'), ('2020-12-31'), ('1980-10-14'), ('2000-06-15');
318
select * from t2 where a='1980-10-14';
321
delete from t2 where a='1980-10-14';
329
insert into t2 values (19700101+28-1);
330
insert into t2 values (19700201+28-1);
331
insert into t2 values (19700301+28-1);
332
insert into t2 values (19700101+27-1);
333
insert into t2 values (19700201+27-1);
334
insert into t2 values (19700301+27-1);
335
insert into t2 values (19700101+26-1);
336
insert into t2 values (19700201+26-1);
337
insert into t2 values (19700301+26-1);
338
insert into t2 values (19700101+25-1);
339
insert into t2 values (19700201+25-1);
340
insert into t2 values (19700301+25-1);
341
insert into t2 values (19700101+24-1);
342
insert into t2 values (19700201+24-1);
343
insert into t2 values (19700301+24-1);
344
insert into t2 values (19700101+23-1);
345
insert into t2 values (19700201+23-1);
346
insert into t2 values (19700301+23-1);
347
insert into t2 values (19700101+22-1);
348
insert into t2 values (19700201+22-1);
349
insert into t2 values (19700301+22-1);
350
insert into t2 values (19700101+21-1);
351
insert into t2 values (19700201+21-1);
352
insert into t2 values (19700301+21-1);
353
insert into t2 values (19700101+20-1);
354
insert into t2 values (19700201+20-1);
355
insert into t2 values (19700301+20-1);
356
insert into t2 values (19700101+19-1);
357
insert into t2 values (19700201+19-1);
358
insert into t2 values (19700301+19-1);
359
insert into t2 values (19700101+18-1);
360
insert into t2 values (19700201+18-1);
361
insert into t2 values (19700301+18-1);
362
insert into t2 values (19700101+17-1);
363
insert into t2 values (19700201+17-1);
364
insert into t2 values (19700301+17-1);
365
insert into t2 values (19700101+16-1);
366
insert into t2 values (19700201+16-1);
367
insert into t2 values (19700301+16-1);
368
insert into t2 values (19700101+15-1);
369
insert into t2 values (19700201+15-1);
370
insert into t2 values (19700301+15-1);
371
insert into t2 values (19700101+14-1);
372
insert into t2 values (19700201+14-1);
373
insert into t2 values (19700301+14-1);
374
insert into t2 values (19700101+13-1);
375
insert into t2 values (19700201+13-1);
376
insert into t2 values (19700301+13-1);
377
insert into t2 values (19700101+12-1);
378
insert into t2 values (19700201+12-1);
379
insert into t2 values (19700301+12-1);
380
insert into t2 values (19700101+11-1);
381
insert into t2 values (19700201+11-1);
382
insert into t2 values (19700301+11-1);
383
insert into t2 values (19700101+10-1);
384
insert into t2 values (19700201+10-1);
385
insert into t2 values (19700301+10-1);
386
insert into t2 values (19700101+9-1);
387
insert into t2 values (19700201+9-1);
388
insert into t2 values (19700301+9-1);
389
insert into t2 values (19700101+8-1);
390
insert into t2 values (19700201+8-1);
391
insert into t2 values (19700301+8-1);
392
insert into t2 values (19700101+7-1);
393
insert into t2 values (19700201+7-1);
394
insert into t2 values (19700301+7-1);
395
insert into t2 values (19700101+6-1);
396
insert into t2 values (19700201+6-1);
397
insert into t2 values (19700301+6-1);
398
insert into t2 values (19700101+5-1);
399
insert into t2 values (19700201+5-1);
400
insert into t2 values (19700301+5-1);
401
insert into t2 values (19700101+4-1);
402
insert into t2 values (19700201+4-1);
403
insert into t2 values (19700301+4-1);
404
insert into t2 values (19700101+3-1);
405
insert into t2 values (19700201+3-1);
406
insert into t2 values (19700301+3-1);
407
insert into t2 values (19700101+2-1);
408
insert into t2 values (19700201+2-1);
409
insert into t2 values (19700301+2-1);
410
insert into t2 values (19700101+1-1);
411
insert into t2 values (19700201+1-1);
412
insert into t2 values (19700301+1-1);
413
select count(*) from t2;
503
create table t3 (a date not null, primary key(a)) engine='InnoDB'
504
partition by range (month(a)) subpartition by key (a)
506
partition quarter1 values less than (4),
507
partition quarter2 values less than (7),
508
partition quarter3 values less than (10),
509
partition quarter4 values less than (13)
511
show create table t3;
513
t3 CREATE TABLE `t3` (
516
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (month(a)) SUBPARTITION BY KEY (a) SUBPARTITIONS 3 (PARTITION quarter1 VALUES LESS THAN (4) ENGINE = InnoDB, PARTITION quarter2 VALUES LESS THAN (7) ENGINE = InnoDB, PARTITION quarter3 VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION quarter4 VALUES LESS THAN (13) ENGINE = InnoDB) */
518
insert into t3 values (adddate(19700101,interval 12-1 month));
519
insert into t3 values (adddate(19700101,interval 11-1 month));
520
insert into t3 values (adddate(19700101,interval 10-1 month));
521
insert into t3 values (adddate(19700101,interval 9-1 month));
522
insert into t3 values (adddate(19700101,interval 8-1 month));
523
insert into t3 values (adddate(19700101,interval 7-1 month));
524
insert into t3 values (adddate(19700101,interval 6-1 month));
525
insert into t3 values (adddate(19700101,interval 5-1 month));
526
insert into t3 values (adddate(19700101,interval 4-1 month));
527
insert into t3 values (adddate(19700101,interval 3-1 month));
528
insert into t3 values (adddate(19700101,interval 2-1 month));
529
insert into t3 values (adddate(19700101,interval 1-1 month));
530
select count(*) from t3;
548
create table t4 (a date not null, primary key(a)) engine='InnoDB'
549
partition by list (month(a)) subpartition by key (a)
551
partition quarter1 values in (1,2,3),
552
partition quarter2 values in (4,5,6),
553
partition quarter3 values in (7,8,9),
554
partition quarter4 values in (10,11,12)
556
show create table t4;
558
t4 CREATE TABLE `t4` (
561
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (month(a)) SUBPARTITION BY KEY (a) SUBPARTITIONS 3 (PARTITION quarter1 VALUES IN (1,2,3) ENGINE = InnoDB, PARTITION quarter2 VALUES IN (4,5,6) ENGINE = InnoDB, PARTITION quarter3 VALUES IN (7,8,9) ENGINE = InnoDB, PARTITION quarter4 VALUES IN (10,11,12) ENGINE = InnoDB) */
563
insert into t4 values (adddate(19700101,interval 12-1 month));
564
insert into t4 values (adddate(19700101,interval 11-1 month));
565
insert into t4 values (adddate(19700101,interval 10-1 month));
566
insert into t4 values (adddate(19700101,interval 9-1 month));
567
insert into t4 values (adddate(19700101,interval 8-1 month));
568
insert into t4 values (adddate(19700101,interval 7-1 month));
569
insert into t4 values (adddate(19700101,interval 6-1 month));
570
insert into t4 values (adddate(19700101,interval 5-1 month));
571
insert into t4 values (adddate(19700101,interval 4-1 month));
572
insert into t4 values (adddate(19700101,interval 3-1 month));
573
insert into t4 values (adddate(19700101,interval 2-1 month));
574
insert into t4 values (adddate(19700101,interval 1-1 month));
575
select count(*) from t4;
593
create table t1 (a time not null, primary key(a)) engine='InnoDB'
594
partition by key (a) (
595
partition pa1 max_rows=20 min_rows=2,
596
partition pa2 max_rows=30 min_rows=3,
597
partition pa3 max_rows=30 min_rows=4,
598
partition pa4 max_rows=40 min_rows=2);
599
show create table t1;
601
t1 CREATE TABLE `t1` (
604
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) (PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = InnoDB, PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = InnoDB, PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = InnoDB, PARTITION pa4 MAX_ROWS = 40 MIN_ROWS = 2 ENGINE = InnoDB) */
605
insert into t1 values ('21:21:21'), ('12:10:30'), ('03:03:03'), ('23:59');
612
select * from t1 where a=030303;
615
delete from t1 where a=030303;
622
create table t2 (a time not null, primary key(a)) engine='InnoDB'
623
partition by key (a) partitions 12;
624
show create table t2;
626
t2 CREATE TABLE `t2` (
629
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) PARTITIONS 12 */
630
insert into t2 values ('0:1:1'), ('10:11:12'), ('13:14:15'), ('14:15:16');
637
select * from t2 where a='13:14:15';
640
delete from t2 where a='13:14:15';
648
insert into t2 values (000100+59);
649
insert into t2 values (000100+58);
650
insert into t2 values (000100+57);
651
insert into t2 values (000100+56);
652
insert into t2 values (000100+55);
653
insert into t2 values (000100+54);
654
insert into t2 values (000100+53);
655
insert into t2 values (000100+52);
656
insert into t2 values (000100+51);
657
insert into t2 values (000100+50);
658
insert into t2 values (000100+49);
659
insert into t2 values (000100+48);
660
insert into t2 values (000100+47);
661
insert into t2 values (000100+46);
662
insert into t2 values (000100+45);
663
insert into t2 values (000100+44);
664
insert into t2 values (000100+43);
665
insert into t2 values (000100+42);
666
insert into t2 values (000100+41);
667
insert into t2 values (000100+40);
668
insert into t2 values (000100+39);
669
insert into t2 values (000100+38);
670
insert into t2 values (000100+37);
671
insert into t2 values (000100+36);
672
insert into t2 values (000100+35);
673
insert into t2 values (000100+34);
674
insert into t2 values (000100+33);
675
insert into t2 values (000100+32);
676
insert into t2 values (000100+31);
677
insert into t2 values (000100+30);
678
insert into t2 values (000100+29);
679
insert into t2 values (000100+28);
680
insert into t2 values (000100+27);
681
insert into t2 values (000100+26);
682
insert into t2 values (000100+25);
683
insert into t2 values (000100+24);
684
insert into t2 values (000100+23);
685
insert into t2 values (000100+22);
686
insert into t2 values (000100+21);
687
insert into t2 values (000100+20);
688
insert into t2 values (000100+19);
689
insert into t2 values (000100+18);
690
insert into t2 values (000100+17);
691
insert into t2 values (000100+16);
692
insert into t2 values (000100+15);
693
insert into t2 values (000100+14);
694
insert into t2 values (000100+13);
695
insert into t2 values (000100+12);
696
insert into t2 values (000100+11);
697
insert into t2 values (000100+10);
698
insert into t2 values (000100+9);
699
insert into t2 values (000100+8);
700
insert into t2 values (000100+7);
701
insert into t2 values (000100+6);
702
insert into t2 values (000100+5);
703
insert into t2 values (000100+4);
704
insert into t2 values (000100+3);
705
insert into t2 values (000100+2);
706
insert into t2 values (000100+1);
707
select count(*) from t2;
772
create table t3 (a time not null, primary key(a)) engine='InnoDB'
773
partition by range (second(a)) subpartition by key (a)
775
partition quarter1 values less than (16),
776
partition quarter2 values less than (31),
777
partition quarter3 values less than (46),
778
partition quarter4 values less than (61)
780
show create table t3;
782
t3 CREATE TABLE `t3` (
785
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (second(a)) SUBPARTITION BY KEY (a) SUBPARTITIONS 3 (PARTITION quarter1 VALUES LESS THAN (16) ENGINE = InnoDB, PARTITION quarter2 VALUES LESS THAN (31) ENGINE = InnoDB, PARTITION quarter3 VALUES LESS THAN (46) ENGINE = InnoDB, PARTITION quarter4 VALUES LESS THAN (61) ENGINE = InnoDB) */
787
insert into t3 values (100000+59);
788
insert into t3 values (100000+58);
789
insert into t3 values (100000+57);
790
insert into t3 values (100000+56);
791
insert into t3 values (100000+55);
792
insert into t3 values (100000+54);
793
insert into t3 values (100000+53);
794
insert into t3 values (100000+52);
795
insert into t3 values (100000+51);
796
insert into t3 values (100000+50);
797
insert into t3 values (100000+49);
798
insert into t3 values (100000+48);
799
insert into t3 values (100000+47);
800
insert into t3 values (100000+46);
801
insert into t3 values (100000+45);
802
insert into t3 values (100000+44);
803
insert into t3 values (100000+43);
804
insert into t3 values (100000+42);
805
insert into t3 values (100000+41);
806
insert into t3 values (100000+40);
807
insert into t3 values (100000+39);
808
insert into t3 values (100000+38);
809
insert into t3 values (100000+37);
810
insert into t3 values (100000+36);
811
insert into t3 values (100000+35);
812
insert into t3 values (100000+34);
813
insert into t3 values (100000+33);
814
insert into t3 values (100000+32);
815
insert into t3 values (100000+31);
816
insert into t3 values (100000+30);
817
insert into t3 values (100000+29);
818
insert into t3 values (100000+28);
819
insert into t3 values (100000+27);
820
insert into t3 values (100000+26);
821
insert into t3 values (100000+25);
822
insert into t3 values (100000+24);
823
insert into t3 values (100000+23);
824
insert into t3 values (100000+22);
825
insert into t3 values (100000+21);
826
insert into t3 values (100000+20);
827
insert into t3 values (100000+19);
828
insert into t3 values (100000+18);
829
insert into t3 values (100000+17);
830
insert into t3 values (100000+16);
831
insert into t3 values (100000+15);
832
insert into t3 values (100000+14);
833
insert into t3 values (100000+13);
834
insert into t3 values (100000+12);
835
insert into t3 values (100000+11);
836
insert into t3 values (100000+10);
837
insert into t3 values (100000+9);
838
insert into t3 values (100000+8);
839
insert into t3 values (100000+7);
840
insert into t3 values (100000+6);
841
insert into t3 values (100000+5);
842
insert into t3 values (100000+4);
843
insert into t3 values (100000+3);
844
insert into t3 values (100000+2);
845
insert into t3 values (100000+1);
846
select count(*) from t3;
911
create table t4 (a time not null, primary key(a)) engine='InnoDB'
912
partition by list (second(a)) subpartition by key (a)
914
partition quarter1 values in (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15),
915
partition quarter2 values in (16,17,18,19,20,21,22,23,24,25,26,27,28,29,30),
916
partition quarter3 values in (31,32,33,34,35,36,37,38,39,40,41,42,43,44,45),
917
partition quarter4 values in (46,47,48,49,50,51,52,53,54,55,56,57,58,59,60)
919
show create table t4;
921
t4 CREATE TABLE `t4` (
924
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (second(a)) SUBPARTITION BY KEY (a) SUBPARTITIONS 3 (PARTITION quarter1 VALUES IN (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15) ENGINE = InnoDB, PARTITION quarter2 VALUES IN (16,17,18,19,20,21,22,23,24,25,26,27,28,29,30) ENGINE = InnoDB, PARTITION quarter3 VALUES IN (31,32,33,34,35,36,37,38,39,40,41,42,43,44,45) ENGINE = InnoDB, PARTITION quarter4 VALUES IN (46,47,48,49,50,51,52,53,54,55,56,57,58,59,60) ENGINE = InnoDB) */
926
insert into t4 values (100000+59);
927
insert into t4 values (100000+58);
928
insert into t4 values (100000+57);
929
insert into t4 values (100000+56);
930
insert into t4 values (100000+55);
931
insert into t4 values (100000+54);
932
insert into t4 values (100000+53);
933
insert into t4 values (100000+52);
934
insert into t4 values (100000+51);
935
insert into t4 values (100000+50);
936
insert into t4 values (100000+49);
937
insert into t4 values (100000+48);
938
insert into t4 values (100000+47);
939
insert into t4 values (100000+46);
940
insert into t4 values (100000+45);
941
insert into t4 values (100000+44);
942
insert into t4 values (100000+43);
943
insert into t4 values (100000+42);
944
insert into t4 values (100000+41);
945
insert into t4 values (100000+40);
946
insert into t4 values (100000+39);
947
insert into t4 values (100000+38);
948
insert into t4 values (100000+37);
949
insert into t4 values (100000+36);
950
insert into t4 values (100000+35);
951
insert into t4 values (100000+34);
952
insert into t4 values (100000+33);
953
insert into t4 values (100000+32);
954
insert into t4 values (100000+31);
955
insert into t4 values (100000+30);
956
insert into t4 values (100000+29);
957
insert into t4 values (100000+28);
958
insert into t4 values (100000+27);
959
insert into t4 values (100000+26);
960
insert into t4 values (100000+25);
961
insert into t4 values (100000+24);
962
insert into t4 values (100000+23);
963
insert into t4 values (100000+22);
964
insert into t4 values (100000+21);
965
insert into t4 values (100000+20);
966
insert into t4 values (100000+19);
967
insert into t4 values (100000+18);
968
insert into t4 values (100000+17);
969
insert into t4 values (100000+16);
970
insert into t4 values (100000+15);
971
insert into t4 values (100000+14);
972
insert into t4 values (100000+13);
973
insert into t4 values (100000+12);
974
insert into t4 values (100000+11);
975
insert into t4 values (100000+10);
976
insert into t4 values (100000+9);
977
insert into t4 values (100000+8);
978
insert into t4 values (100000+7);
979
insert into t4 values (100000+6);
980
insert into t4 values (100000+5);
981
insert into t4 values (100000+4);
982
insert into t4 values (100000+3);
983
insert into t4 values (100000+2);
984
insert into t4 values (100000+1);
985
select count(*) from t4;
1050
create table t1 (a datetime not null, primary key(a)) engine='InnoDB'
1051
partition by key (a) (
1052
partition pa1 max_rows=20 min_rows=2,
1053
partition pa2 max_rows=30 min_rows=3,
1054
partition pa3 max_rows=30 min_rows=4,
1055
partition pa4 max_rows=40 min_rows=2);
1056
show create table t1;
1058
t1 CREATE TABLE `t1` (
1059
`a` datetime NOT NULL,
1061
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) (PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = InnoDB, PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = InnoDB, PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = InnoDB, PARTITION pa4 MAX_ROWS = 40 MIN_ROWS = 2 ENGINE = InnoDB) */
1062
insert into t1 values ('1975-01-01 21:21:21'), ('2020-12-31 12:10:30'), ('1980-10-14 03:03'), ('2000-06-15 23:59');
1069
select * from t1 where a=19801014030300;
1072
delete from t1 where a=19801014030300;
1079
create table t2 (a datetime not null, primary key(a)) engine='InnoDB'
1080
partition by key (a) partitions 12;
1081
show create table t2;
1083
t2 CREATE TABLE `t2` (
1084
`a` datetime NOT NULL,
1086
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) PARTITIONS 12 */
1087
insert into t2 values ('1975-01-01 0:1:1'), ('2020-12-31 10:11:12'), ('1980-10-14 13:14:15'), ('2000-06-15 14:15:16');
1094
select * from t2 where a='1980-10-14 13:14:15';
1097
delete from t2 where a='1980-10-14 13:14:15';
1105
insert into t2 values (19700101000000+59);
1106
insert into t2 values (19700101000000+58);
1107
insert into t2 values (19700101000000+57);
1108
insert into t2 values (19700101000000+56);
1109
insert into t2 values (19700101000000+55);
1110
insert into t2 values (19700101000000+54);
1111
insert into t2 values (19700101000000+53);
1112
insert into t2 values (19700101000000+52);
1113
insert into t2 values (19700101000000+51);
1114
insert into t2 values (19700101000000+50);
1115
insert into t2 values (19700101000000+49);
1116
insert into t2 values (19700101000000+48);
1117
insert into t2 values (19700101000000+47);
1118
insert into t2 values (19700101000000+46);
1119
insert into t2 values (19700101000000+45);
1120
insert into t2 values (19700101000000+44);
1121
insert into t2 values (19700101000000+43);
1122
insert into t2 values (19700101000000+42);
1123
insert into t2 values (19700101000000+41);
1124
insert into t2 values (19700101000000+40);
1125
insert into t2 values (19700101000000+39);
1126
insert into t2 values (19700101000000+38);
1127
insert into t2 values (19700101000000+37);
1128
insert into t2 values (19700101000000+36);
1129
insert into t2 values (19700101000000+35);
1130
insert into t2 values (19700101000000+34);
1131
insert into t2 values (19700101000000+33);
1132
insert into t2 values (19700101000000+32);
1133
insert into t2 values (19700101000000+31);
1134
insert into t2 values (19700101000000+30);
1135
insert into t2 values (19700101000000+29);
1136
insert into t2 values (19700101000000+28);
1137
insert into t2 values (19700101000000+27);
1138
insert into t2 values (19700101000000+26);
1139
insert into t2 values (19700101000000+25);
1140
insert into t2 values (19700101000000+24);
1141
insert into t2 values (19700101000000+23);
1142
insert into t2 values (19700101000000+22);
1143
insert into t2 values (19700101000000+21);
1144
insert into t2 values (19700101000000+20);
1145
insert into t2 values (19700101000000+19);
1146
insert into t2 values (19700101000000+18);
1147
insert into t2 values (19700101000000+17);
1148
insert into t2 values (19700101000000+16);
1149
insert into t2 values (19700101000000+15);
1150
insert into t2 values (19700101000000+14);
1151
insert into t2 values (19700101000000+13);
1152
insert into t2 values (19700101000000+12);
1153
insert into t2 values (19700101000000+11);
1154
insert into t2 values (19700101000000+10);
1155
insert into t2 values (19700101000000+9);
1156
insert into t2 values (19700101000000+8);
1157
insert into t2 values (19700101000000+7);
1158
insert into t2 values (19700101000000+6);
1159
insert into t2 values (19700101000000+5);
1160
insert into t2 values (19700101000000+4);
1161
insert into t2 values (19700101000000+3);
1162
insert into t2 values (19700101000000+2);
1163
insert into t2 values (19700101000000+1);
1164
select count(*) from t2;
1229
create table t3 (a datetime not null, primary key(a)) engine='InnoDB'
1230
partition by range (month(a)) subpartition by key (a)
1232
partition quarter1 values less than (4),
1233
partition quarter2 values less than (7),
1234
partition quarter3 values less than (10),
1235
partition quarter4 values less than (13)
1237
show create table t3;
1239
t3 CREATE TABLE `t3` (
1240
`a` datetime NOT NULL,
1242
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (month(a)) SUBPARTITION BY KEY (a) SUBPARTITIONS 3 (PARTITION quarter1 VALUES LESS THAN (4) ENGINE = InnoDB, PARTITION quarter2 VALUES LESS THAN (7) ENGINE = InnoDB, PARTITION quarter3 VALUES LESS THAN (10) ENGINE = InnoDB, PARTITION quarter4 VALUES LESS THAN (13) ENGINE = InnoDB) */
1244
insert into t3 values (adddate(19700101000000,interval 12-1 month));
1245
insert into t3 values (adddate(19700101000000,interval 11-1 month));
1246
insert into t3 values (adddate(19700101000000,interval 10-1 month));
1247
insert into t3 values (adddate(19700101000000,interval 9-1 month));
1248
insert into t3 values (adddate(19700101000000,interval 8-1 month));
1249
insert into t3 values (adddate(19700101000000,interval 7-1 month));
1250
insert into t3 values (adddate(19700101000000,interval 6-1 month));
1251
insert into t3 values (adddate(19700101000000,interval 5-1 month));
1252
insert into t3 values (adddate(19700101000000,interval 4-1 month));
1253
insert into t3 values (adddate(19700101000000,interval 3-1 month));
1254
insert into t3 values (adddate(19700101000000,interval 2-1 month));
1255
insert into t3 values (adddate(19700101000000,interval 1-1 month));
1256
select count(*) from t3;
1274
create table t4 (a datetime not null, primary key(a)) engine='InnoDB'
1275
partition by list (month(a)) subpartition by key (a)
1277
partition quarter1 values in (1,2,3),
1278
partition quarter2 values in (4,5,6),
1279
partition quarter3 values in (7,8,9),
1280
partition quarter4 values in (10,11,12)
1282
show create table t4;
1284
t4 CREATE TABLE `t4` (
1285
`a` datetime NOT NULL,
1287
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (month(a)) SUBPARTITION BY KEY (a) SUBPARTITIONS 3 (PARTITION quarter1 VALUES IN (1,2,3) ENGINE = InnoDB, PARTITION quarter2 VALUES IN (4,5,6) ENGINE = InnoDB, PARTITION quarter3 VALUES IN (7,8,9) ENGINE = InnoDB, PARTITION quarter4 VALUES IN (10,11,12) ENGINE = InnoDB) */
1289
insert into t4 values (adddate(19700101000000,interval 12-1 month));
1290
insert into t4 values (adddate(19700101000000,interval 11-1 month));
1291
insert into t4 values (adddate(19700101000000,interval 10-1 month));
1292
insert into t4 values (adddate(19700101000000,interval 9-1 month));
1293
insert into t4 values (adddate(19700101000000,interval 8-1 month));
1294
insert into t4 values (adddate(19700101000000,interval 7-1 month));
1295
insert into t4 values (adddate(19700101000000,interval 6-1 month));
1296
insert into t4 values (adddate(19700101000000,interval 5-1 month));
1297
insert into t4 values (adddate(19700101000000,interval 4-1 month));
1298
insert into t4 values (adddate(19700101000000,interval 3-1 month));
1299
insert into t4 values (adddate(19700101000000,interval 2-1 month));
1300
insert into t4 values (adddate(19700101000000,interval 1-1 month));
1301
select count(*) from t4;
1319
create table t1 (a year not null, primary key(a)) engine='InnoDB'
1320
partition by key (a) (
1321
partition pa1 max_rows=20 min_rows=2,
1322
partition pa2 max_rows=30 min_rows=3,
1323
partition pa3 max_rows=30 min_rows=4,
1324
partition pa4 max_rows=40 min_rows=2);
1325
show create table t1;
1327
t1 CREATE TABLE `t1` (
1328
`a` year(4) NOT NULL,
1330
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) (PARTITION pa1 MAX_ROWS = 20 MIN_ROWS = 2 ENGINE = InnoDB, PARTITION pa2 MAX_ROWS = 30 MIN_ROWS = 3 ENGINE = InnoDB, PARTITION pa3 MAX_ROWS = 30 MIN_ROWS = 4 ENGINE = InnoDB, PARTITION pa4 MAX_ROWS = 40 MIN_ROWS = 2 ENGINE = InnoDB) */
1331
insert into t1 values ('1975'), (2020), ('1980'), ('2000');
1338
select * from t1 where a=1980;
1341
delete from t1 where a=1980;
1348
create table t2 (a year not null, primary key(a)) engine='InnoDB'
1349
partition by key (a) partitions 12;
1350
show create table t2;
1352
t2 CREATE TABLE `t2` (
1353
`a` year(4) NOT NULL,
1355
) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY (a) PARTITIONS 12 */
1356
insert into t2 values ('1975'), ('2020'), ('1980'), ('2000');
1363
select * from t2 where a='1980';
1366
delete from t2 where a='1980';
1375
Warning 1264 Out of range value for column 'a' at row 1
1376
select count(*) from t2;