1
drop table if exists t1;
11
(partition x1 values less than (5),
12
partition x2 values less than (10),
13
partition x3 values less than (20));
14
INSERT into t1 values (1, 1, 1);
15
INSERT into t1 values (6, 1, 1);
16
INSERT into t1 values (10, 1, 1);
17
INSERT into t1 values (15, 1, 1);
18
select * from information_schema.partitions where table_name= 't1';
19
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PARTITION_NAME SUBPARTITION_NAME PARTITION_ORDINAL_POSITION SUBPARTITION_ORDINAL_POSITION PARTITION_METHOD SUBPARTITION_METHOD PARTITION_EXPRESSION SUBPARTITION_EXPRESSION PARTITION_DESCRIPTION TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE CREATE_TIME UPDATE_TIME CHECK_TIME CHECKSUM PARTITION_COMMENT NODEGROUP TABLESPACE_NAME
20
NULL test t1 x1 NULL 1 NULL RANGE NULL a NULL 5 0 0 0 # 0 0 # # NULL NULL default 0 default
21
NULL test t1 x2 NULL 2 NULL RANGE NULL a NULL 10 0 0 0 # 0 0 # # NULL NULL default 0 default
22
NULL test t1 x3 NULL 3 NULL RANGE NULL a NULL 20 0 0 0 # 0 0 # # NULL NULL default 0 default
23
select * from t1 order by a;
29
select * from t1 where a=1 order by a;
32
select * from t1 where a=15 and b=1 order by a;
35
select * from t1 where a=21 and b=1 order by a;
37
select * from t1 where a=21 order by a;
39
select * from t1 where a in (1,6,10,21) order by a;
44
select * from t1 where b=1 and a in (1,6,10,21) order by a;
57
partition by range (b)
59
(partition x1 values less than (5),
60
partition x2 values less than (10),
61
partition x3 values less than (20));
62
INSERT into t1 values (1, 1, 1);
63
INSERT into t1 values (2, 6, 1);
64
INSERT into t1 values (3, 10, 1);
65
INSERT into t1 values (4, 15, 1);
66
select * from t1 order by a;
72
UPDATE t1 set a = 5 WHERE b = 15;
73
select * from t1 order by a;
79
UPDATE t1 set a = 6 WHERE a = 5;
80
select * from t1 order by a;
86
select * from t1 where b=1 order by b;
89
select * from t1 where b=15 and a=1 order by b;
91
select * from t1 where b=21 and a=1 order by b;
93
select * from t1 where b=21 order by b;
95
select * from t1 where b in (1,6,10,21) order by b;
100
select * from t1 where a in (1,2,5,6) order by b;
105
select * from t1 where a=1 and b in (1,6,10,21) order by b;
108
DELETE from t1 WHERE b = 6;
109
DELETE from t1 WHERE a = 6;
110
show create table t1;
112
t1 CREATE TABLE `t1` (
113
`a` int(11) NOT NULL,
114
`b` int(11) NOT NULL,
115
`c` int(11) NOT NULL,
118
) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY RANGE (b) (PARTITION x1 VALUES LESS THAN (5) ENGINE = ndbcluster, PARTITION x2 VALUES LESS THAN (10) ENGINE = ndbcluster, PARTITION x3 VALUES LESS THAN (20) ENGINE = ndbcluster)
121
(id MEDIUMINT NOT NULL,
125
d DECIMAL(10,4) DEFAULT 0,
127
total BIGINT UNSIGNED,
130
PARTITION BY RANGE (YEAR(t))
131
(PARTITION p0 VALUES LESS THAN (1901),
132
PARTITION p1 VALUES LESS THAN (1946),
133
PARTITION p2 VALUES LESS THAN (1966),
134
PARTITION p3 VALUES LESS THAN (1986),
135
PARTITION p4 VALUES LESS THAN (2005),
136
PARTITION p5 VALUES LESS THAN MAXVALUE);
137
INSERT INTO t1 VALUES (0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
139
id b1 vc bc d f total y t
140
0 NULL NULL NULL NULL NULL NULL NULL NULL
141
ALTER TABLE t1 ENGINE=MYISAM;
143
id b1 vc bc d f total y t
144
0 NULL NULL NULL NULL NULL NULL NULL NULL
146
CREATE LOGFILE GROUP lg1
147
ADD UNDOFILE 'undofile.dat'
151
CREATE TABLESPACE ts1
152
ADD DATAFILE 'datafile.dat'
153
USE LOGFILE GROUP lg1
156
CREATE TABLE test.t1 (
164
TABLESPACE ts1 STORAGE DISK ENGINE=NDB
165
PARTITION BY LIST (a1)
166
(PARTITION p0 VALUES IN (1,2,3,4,5),
167
PARTITION p1 VALUES IN (6,7,8,9, 10),
168
PARTITION p2 VALUES IN (11, 12, 13, 14, 15));
169
ALTER TABLE test.t1 DROP COLUMN a6;
170
ALTER TABLE test.t1 ADD COLUMN a6 VARCHAR(255);
171
SELECT COUNT(*) FROM test.t1;
174
ALTER TABLE test.t1 DROP COLUMN a4;
175
SELECT COUNT(*) FROM test.t1;
179
CREATE TABLE test.t1 (
187
TABLESPACE ts1 STORAGE DISK ENGINE=NDB
188
PARTITION BY HASH(a1)
190
SELECT COUNT(*) FROM test.t1;
193
ALTER TABLE test.t1 DROP COLUMN a4;
194
SELECT COUNT(*) FROM test.t1;
199
DROP DATAFILE 'datafile.dat'
201
DROP TABLESPACE ts1 ENGINE=NDB;
202
DROP LOGFILE GROUP lg1 ENGINE=NDB;
204
(id MEDIUMINT NOT NULL,
208
d DECIMAL(10,4) DEFAULT 0,
210
total BIGINT UNSIGNED,
213
PARTITION BY LIST(id)
214
(PARTITION p0 VALUES IN (2, 4),
215
PARTITION p1 VALUES IN (42, 142));
216
INSERT INTO t1 VALUES (2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
218
id b1 vc bc d f total y t
219
2 NULL NULL NULL NULL NULL NULL NULL NULL
220
ALTER TABLE t1 ADD PARTITION
221
(PARTITION p2 VALUES IN (412));
223
id b1 vc bc d f total y t
224
2 NULL NULL NULL NULL NULL NULL NULL NULL
232
(partition x123 values in (1,5,6),
233
partition x234 values in (4,7,8));
234
INSERT into t1 VALUES (5,1,1);
238
UPDATE t1 SET a=8 WHERE a=5 AND b=1;
243
CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) engine=ndb
244
PARTITION BY RANGE(f1)
245
( PARTITION part1 VALUES LESS THAN (2),
246
PARTITION part2 VALUES LESS THAN (1000));
247
INSERT INTO t1 VALUES(1, '---1---');
248
INSERT INTO t1 VALUES(2, '---2---');
249
select * from t1 order by f1;
253
UPDATE t1 SET f1 = f1 + 4 WHERE f1 = 2;
254
select * from t1 order by f1;
258
UPDATE t1 SET f1 = f1 + 4 WHERE f1 = 1;
259
select * from t1 order by f1;