--source include/have_ndb.inc # # Partition by key, basic. # CREATE TABLE t1 (a int, b int, c int, d int, PRIMARY KEY(a,b,c)) ENGINE = NDB PARTITION BY KEY (a,b); insert into t1 values (1,1,1,1); select * from t1; update t1 set d = 2 where a = 1 and b = 1 and c = 1; select * from t1; delete from t1; select * from t1; drop table t1; # # Partition by hash, basic. # CREATE TABLE t1 ( ol_o_id int NOT NULL, ol_d_id int NOT NULL, ol_w_id int NOT NULL, ol_number int NOT NULL, ol_tmp int, PRIMARY KEY (ol_w_id, ol_d_id, ol_o_id, ol_number) ) ENGINE=NDB PARTITION BY HASH (ol_w_id); insert into t1 values (1,0,0,0,0),(1,0,0,1,0),(1,0,0,2,0),(1,1,0,0,0),(1,1,0,1,0); insert into t1 values (2,0,0,0,0),(4,0,0,0,0),(4,0,0,1,0); insert into t1 values (0,1,1,4,0),(0,1,1,5,0); # Only rows affected. SELECT * FROM t1 WHERE ol_w_id = 1 AND ol_d_id = 1 AND ol_o_id = 0; SELECT SUM(ol_number) FROM t1 WHERE ol_o_id = 0 AND ol_w_id = 1 AND ol_d_id = 1; drop table t1; # # Partition by list, basic. # CREATE TABLE t1 ( f_int1 INTEGER NOT NULL, f_int2 INTEGER NOT NULL, f_char1 CHAR(10), f_char2 CHAR(10), f_charbig VARCHAR(1000), PRIMARY KEY (f_int1,f_int2)) ENGINE = NDB PARTITION BY LIST(MOD(f_int1 + f_int2,4)) (PARTITION part_3 VALUES IN (-3), PARTITION part_2 VALUES IN (-2), PARTITION part_1 VALUES IN (-1), PARTITION part0 VALUES IN (0), PARTITION part1 VALUES IN (1), PARTITION part2 VALUES IN (2), PARTITION part3 VALUES IN (3,4,5)); INSERT INTO t1 SET f_int1 = -2, f_int2 = 20, f_char1 = '20', f_char2 = '20', f_charbig = '===20==='; INSERT INTO t1 SET f_int1 = 1, f_int2 = 1, f_char1 = '1', f_char2 = '1', f_charbig = '===1==='; INSERT INTO t1 SET f_int1 = 2, f_int2 = 1, f_char1 = '1', f_char2 = '1', f_charbig = '===1==='; INSERT INTO t1 SET f_int1 = 3, f_int2 = 1, f_char1 = '1', f_char2 = '1', f_charbig = '===1==='; INSERT INTO t1 SET f_int1 = 4, f_int2 = 1, f_char1 = '1', f_char2 = '1', f_charbig = '===1==='; INSERT INTO t1 SET f_int1 = 5, f_int2 = 1, f_char1 = '1', f_char2 = '1', f_charbig = '===1==='; INSERT INTO t1 SET f_int1 = 20, f_int2 = 1, f_char1 = '1', f_char2 = '1', f_charbig = '===1==='; SELECT * FROM t1 ORDER BY f_int1; DROP TABLE t1; # # Partition by range, basic. # CREATE TABLE t1 ( a int not null, b int not null, c int not null, primary key(a,b), index (a)) engine = ndb partition by range (a) partitions 3 (partition x1 values less than (5), partition x2 values less than (10), partition x3 values less than (20)); # Simple insert and verify test INSERT into t1 values (1, 1, 1); INSERT into t1 values (6, 1, 1); INSERT into t1 values (10, 1, 1); INSERT into t1 values (15, 1, 1); select * from t1 order by a; drop table t1;