MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
partition_timestamp.inc
1 eval create table t1 (a timestamp not null, primary key(a)) engine=$engine
2 partition by key (a) (
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);
7 show create table t1;
8 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');
9 select * from t1;
10 select * from t1 where a=19801014030300;
11 delete from t1 where a=19801014030300;
12 select * from t1;
13 drop table t1;
14 
15 eval create table t2 (a timestamp not null, primary key(a)) engine=$engine
16 partition by key (a) partitions 12;
17 show create table t2;
18 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');
19 select * from t2;
20 select * from t2 where a='1980-10-14 13:14:15';
21 delete from t2 where a='1980-10-14 13:14:15';
22 select * from t2;
23 delete from t2;
24 let $count=59;
25 --echo $count inserts;
26 #--disable_query_log
27 while ($count)
28 {
29 eval insert into t2 values (19710101000000+$count);
30 dec $count;
31 }
32 select count(*) from t2;
33 select * from t2;
34 drop table t2;
35 
36 ################################################################################
37 # The following 2 tests are no longer valid after bug #42849 has been fixed:
38 # it is not possible to use a timezone-dependent (such as month(timestamp_col)
39 # or just a timestamp_col in a numeric context) anymore.
40 ################################################################################
41 
42 # eval create table t3 (a timestamp not null, primary key(a)) engine=$engine
43 # partition by range (month(a)) subpartition by key (a)
44 # subpartitions 3 (
45 # partition quarter1 values less than (4),
46 # partition quarter2 values less than (7),
47 # partition quarter3 values less than (10),
48 # partition quarter4 values less than (13)
49 # );
50 # show create table t3;
51 # let $count=12;
52 # --echo $count inserts;
53 # while ($count)
54 # {
55 # eval insert into t3 values (date_add('1970-01-01 00:00:00',interval $count-1 month));
56 # dec $count;
57 # }
58 # select count(*) from t3;
59 # select * from t3;
60 # drop table t3;
61 
62 # eval create table t4 (a timestamp not null, primary key(a)) engine=$engine
63 # partition by list (month(a)) subpartition by key (a)
64 # subpartitions 3 (
65 # partition quarter1 values in (0,1,2,3),
66 # partition quarter2 values in (4,5,6),
67 # partition quarter3 values in (7,8,9),
68 # partition quarter4 values in (10,11,12)
69 # );
70 # show create table t4;
71 # let $count=12;
72 # --echo $count inserts;
73 # while ($count)
74 # {
75 # eval insert into t4 values (date_add('1970-01-01 00:00:00',interval $count-1 month));
76 # dec $count;
77 # }
78 # select count(*) from t4;
79 # select * from t4;
80 # drop table t4;