You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tests/integration_tests/partition_table/data/prepare.sql
+31-31Lines changed: 31 additions & 31 deletions
Original file line number
Diff line number
Diff line change
@@ -3,11 +3,11 @@ drop database if exists `partition_table2`;
3
3
createdatabase `partition_table`;
4
4
use `partition_table`;
5
5
6
-
createtablet (a int, primary key (a)) partition by hash(a) partitions 5;
7
-
insert into t values (1),(2),(3),(4),(5),(6);
8
-
insert into t values (7),(8),(9);
9
-
altertable t truncate partition p3;
10
-
update t set a=a+10where a=2;
6
+
--create table t (a int, primary key (a)) partition by hash(a) partitions 5;
7
+
--insert into t values (1),(2),(3),(4),(5),(6);
8
+
--insert into t values (7),(8),(9);
9
+
--alter table t truncate partition p3;
10
+
--update t set a=a+10 where a=2;
11
11
12
12
13
13
createtablet1 (a intprimary key) PARTITION BY RANGE ( a ) ( PARTITION p0 VALUES LESS THAN (6),PARTITION p1 VALUES LESS THAN (11),PARTITION p2 VALUES LESS THAN (21));
@@ -21,38 +21,38 @@ alter table t1 drop partition p1;
21
21
insert into t1 values (7),(8),(9);
22
22
update t1 set a=a+10where a=9;
23
23
24
-
/* Remove partitioning + add partitioning back again */
25
-
altertable t remove partitioning;
26
-
insert into t values (20),(21),(22),(23),(24),(25);
27
-
altertable t partition by hash (a) partitions 5;
28
-
insert into t values (30),(31),(32),(33),(34),(35);
24
+
--/* Remove partitioning + add partitioning back again */
25
+
--alter table t remove partitioning;
26
+
--insert into t values (20),(21),(22),(23),(24),(25);
27
+
--alter table t partition by hash (a) partitions 5;
28
+
--insert into t values (30),(31),(32),(33),(34),(35);
29
29
30
30
/* exchange partition case 1: source table and target table in same database */
31
31
createtablet2 (a intprimary key);
32
32
ALTERTABLE t1 EXCHANGE PARTITION p3 WITH TABLE t2;
33
33
insert into t2 values (100),(101),(102),(103),(104),(105); /*these values will be replicated to in downstream t2*/
34
34
insert into t1 values (25),(29); /*these values will be replicated to in downstream t1.p3*/
35
35
36
-
/* exchange partition ccase 2: source table and target table in different database */
37
-
createdatabase `partition_table2`;
38
-
createtablepartition_table2.t2 (a intprimary key);
39
-
ALTERTABLE t1 EXCHANGE PARTITION p3 WITH TABLE partition_table2.t2;
40
-
insert intopartition_table2.t2values (1002),(1012),(1022),(1032),(1042),(1052); /*these values will be replicated to in downstream t2*/
41
-
insert into t1 values (21),(28); /*these values will be replicated to in downstream t1.p3*/
42
-
43
-
ALTERTABLE t1 REORGANIZE PARTITION p0,p2 INTO (PARTITION p0 VALUES LESS THAN (5), PARTITION p1 VALUES LESS THAN (10), PARTITION p2 VALUES LESS THAN (21));
44
-
insert into t1 values (-1),(6),(13);
45
-
update t1 set a=a-22where a=20;
46
-
deletefrom t1 where a =5;
47
-
ALTERTABLE t1 REORGANIZE PARTITION p2,p3,p4 INTO (PARTITION p2 VALUES LESS THAN (20), PARTITION p3 VALUES LESS THAN (26), PARTITION p4 VALUES LESS THAN (35), PARTITION pMax VALUES LESS THAN (MAXVALUE));
48
-
insert into t1 values (-3),(5),(14),(22),(30),(100);
49
-
update t1 set a=a-16where a=12;
50
-
deletefrom t1 where a =29;
51
-
ALTERTABLE t1 REORGANIZE PARTITION p2,p3,p4,pMax INTO (PARTITION pRest VALUES LESS THAN (MAXVALUE));
52
-
53
-
/* Change partitioning to key based and then back to range */
54
-
altertable t1 partition by key(a) partitions 7;
55
-
insert into t1 values (-2001),(2001),(2002),(-2002),(-2003),(2003),(-2004),(2004),(-2005),(2005),(2006),(-2006),(2007),(-2007);
56
-
ALTERTABLE t1 partition by range(a) (partition p0 values less than (5), PARTITION p2 VALUES LESS THAN (20), PARTITION p3 VALUES LESS THAN (26), PARTITION p4 VALUES LESS THAN (35), PARTITION pMax VALUES LESS THAN (MAXVALUE));
36
+
--/* exchange partition ccase 2: source table and target table in different database */
37
+
--create database `partition_table2`;
38
+
--create table partition_table2.t2 (a int primary key);
39
+
--ALTER TABLE t1 EXCHANGE PARTITION p3 WITH TABLE partition_table2.t2;
40
+
--insert into partition_table2.t2 values (1002),(1012),(1022),(1032),(1042),(1052); /*these values will be replicated to in downstream t2*/
41
+
--insert into t1 values (21),(28); /*these values will be replicated to in downstream t1.p3*/
42
+
--
43
+
--ALTER TABLE t1 REORGANIZE PARTITION p0,p2 INTO (PARTITION p0 VALUES LESS THAN (5), PARTITION p1 VALUES LESS THAN (10), PARTITION p2 VALUES LESS THAN (21));
44
+
--insert into t1 values (-1),(6),(13);
45
+
--update t1 set a=a-22 where a=20;
46
+
--delete from t1 where a = 5;
47
+
--ALTER TABLE t1 REORGANIZE PARTITION p2,p3,p4 INTO (PARTITION p2 VALUES LESS THAN (20), PARTITION p3 VALUES LESS THAN (26), PARTITION p4 VALUES LESS THAN (35), PARTITION pMax VALUES LESS THAN (MAXVALUE));
48
+
--insert into t1 values (-3),(5),(14),(22),(30),(100);
49
+
--update t1 set a=a-16 where a=12;
50
+
--delete from t1 where a = 29;
51
+
--ALTER TABLE t1 REORGANIZE PARTITION p2,p3,p4,pMax INTO (PARTITION pRest VALUES LESS THAN (MAXVALUE));
52
+
--
53
+
--/* Change partitioning to key based and then back to range */
54
+
--alter table t1 partition by key(a) partitions 7;
55
+
--insert into t1 values (-2001),(2001),(2002),(-2002),(-2003),(2003),(-2004),(2004),(-2005),(2005),(2006),(-2006),(2007),(-2007);
56
+
--ALTER TABLE t1 partition by range(a) (partition p0 values less than (5), PARTITION p2 VALUES LESS THAN (20), PARTITION p3 VALUES LESS THAN (26), PARTITION p4 VALUES LESS THAN (35), PARTITION pMax VALUES LESS THAN (MAXVALUE));
0 commit comments