ndb_partition_range.result 5.46 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
drop table if exists t1;
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));
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);
18 19 20 21 22
select * from information_schema.partitions where table_name= 't1';
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
NULL	test	t1	x1	NULL	1	NULL	RANGE	NULL	a	NULL	5	0	0	0	#	0	0	#	#	NULL	NULL	default	0	default
NULL	test	t1	x2	NULL	2	NULL	RANGE	NULL	a	NULL	10	0	0	0	#	0	0	#	#	NULL	NULL	default	0	default
NULL	test	t1	x3	NULL	3	NULL	RANGE	NULL	a	NULL	20	0	0	0	#	0	0	#	#	NULL	NULL	default	0	default
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
select * from t1 order by a;
a	b	c
1	1	1
6	1	1
10	1	1
15	1	1
select * from t1 where a=1 order by a;
a	b	c
1	1	1
select * from t1 where a=15 and b=1 order by a;
a	b	c
15	1	1
select * from t1 where a=21 and b=1 order by a;
a	b	c
select * from t1 where a=21 order by a;
a	b	c
select * from t1 where a in (1,6,10,21) order by a;
a	b	c
1	1	1
6	1	1
10	1	1
select * from t1 where b=1 and a in (1,6,10,21) order by a;
a	b	c
1	1	1
6	1	1
10	1	1
drop table t1;
CREATE TABLE t1 (
a int not null,
b int not null,
c int not null,
primary key(b),
unique (a))
engine = ndb
partition by range (b)
partitions 3
(partition x1 values less than (5),
partition x2 values less than (10),
partition x3 values less than (20));
INSERT into t1 values (1, 1, 1);
INSERT into t1 values (2, 6, 1);
INSERT into t1 values (3, 10, 1);
INSERT into t1 values (4, 15, 1);
select * from t1 order by a;
a	b	c
1	1	1
2	6	1
3	10	1
4	15	1
UPDATE t1 set a = 5 WHERE b = 15;
select * from t1 order by a;
a	b	c
1	1	1
2	6	1
3	10	1
5	15	1
UPDATE t1 set a = 6 WHERE a = 5;
select * from t1 order by a;
a	b	c
1	1	1
2	6	1
3	10	1
6	15	1
select * from t1 where b=1 order by b;
a	b	c
1	1	1
select * from t1 where b=15 and a=1 order by b;
a	b	c
select * from t1 where b=21 and a=1 order by b;
a	b	c
select * from t1 where b=21 order by b;
a	b	c
select * from t1 where b in (1,6,10,21) order by b;
a	b	c
1	1	1
2	6	1
3	10	1
select * from t1 where a in (1,2,5,6) order by b;
a	b	c
1	1	1
2	6	1
6	15	1
select * from t1 where a=1 and b in (1,6,10,21) order by b;
a	b	c
1	1	1
DELETE from t1 WHERE b = 6;
DELETE from t1 WHERE a = 6;
110 111 112 113 114 115
show create table t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `a` int(11) NOT NULL,
  `b` int(11) NOT NULL,
  `c` int(11) NOT NULL,
116
  PRIMARY KEY (`b`),
117
  UNIQUE KEY `a` (`a`)
unknown's avatar
merge  
unknown committed
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)
119
drop table t1;
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200
CREATE TABLE t1
(id MEDIUMINT NOT NULL,
b1 BIT(8),
vc VARCHAR(255),
bc CHAR(255),
d DECIMAL(10,4) DEFAULT 0,
f FLOAT DEFAULT 0,
total BIGINT UNSIGNED,
y YEAR,
t DATE) ENGINE=NDB
PARTITION BY RANGE (YEAR(t))
(PARTITION p0 VALUES LESS THAN (1901),
PARTITION p1 VALUES LESS THAN (1946),
PARTITION p2 VALUES LESS THAN (1966),
PARTITION p3 VALUES LESS THAN (1986),
PARTITION p4 VALUES LESS THAN (2005),
PARTITION p5 VALUES LESS THAN MAXVALUE);
INSERT INTO t1 VALUES (0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
SELECT * FROM t1;
id	b1	vc	bc	d	f	total	y	t
0	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
ALTER TABLE t1 ENGINE=MYISAM;
SELECT * FROM t1;
id	b1	vc	bc	d	f	total	y	t
0	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
DROP TABLE t1;
CREATE LOGFILE GROUP lg1
ADD UNDOFILE 'undofile.dat'
  INITIAL_SIZE 16M
UNDO_BUFFER_SIZE=1M
ENGINE=NDB;
CREATE TABLESPACE ts1
ADD DATAFILE 'datafile.dat'
  USE LOGFILE GROUP lg1
INITIAL_SIZE 12M
ENGINE NDB;
CREATE TABLE test.t1 (
a1 INT,
a2 TEXT NOT NULL,
a3 BIT NOT NULL,
a4 DECIMAL(8,3),
a5 INT NOT NULL,
a6 VARCHAR(255),
PRIMARY KEY(a1))
TABLESPACE ts1 STORAGE DISK ENGINE=NDB
PARTITION BY LIST (a1)
(PARTITION p0 VALUES IN (1,2,3,4,5),
PARTITION p1 VALUES IN (6,7,8,9, 10),
PARTITION p2 VALUES IN (11, 12, 13, 14, 15));
SELECT COUNT(*) FROM test.t1;
COUNT(*)
15
ALTER TABLE test.t1 DROP COLUMN a4;
SELECT COUNT(*) FROM test.t1;
COUNT(*)
15
DROP TABLE t1;
CREATE TABLE test.t1 (
a1 INT,
a2 TEXT NOT NULL,
a3 BIT NOT NULL,
a4 DECIMAL(8,3),
a5 INT NOT NULL,
a6 VARCHAR(255),
PRIMARY KEY(a1))
TABLESPACE ts1 STORAGE DISK ENGINE=NDB
PARTITION BY HASH(a1)
PARTITIONS 4;
SELECT COUNT(*) FROM test.t1;
COUNT(*)
15
ALTER TABLE test.t1 DROP COLUMN a4;
SELECT COUNT(*) FROM test.t1;
COUNT(*)
15
DROP TABLE t1;
ALTER TABLESPACE ts1 
DROP DATAFILE 'datafile.dat' 
ENGINE=NDB;
DROP TABLESPACE ts1 ENGINE=NDB;
DROP LOGFILE GROUP lg1 ENGINE=NDB;
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223
CREATE TABLE t1
(id MEDIUMINT NOT NULL,
b1 BIT(8),
vc VARCHAR(255),
bc CHAR(255),
d DECIMAL(10,4) DEFAULT 0,
f FLOAT DEFAULT 0,
total BIGINT UNSIGNED,
y YEAR,
t DATE) ENGINE=NDB
PARTITION BY LIST(id)
(PARTITION p0 VALUES IN (2, 4),
PARTITION p1 VALUES IN (42, 142));
INSERT INTO t1 VALUES (2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
SELECT * FROM t1;
id	b1	vc	bc	d	f	total	y	t
2	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
ALTER TABLE t1 ADD PARTITION
(PARTITION p2 VALUES IN (412));
SELECT * FROM t1;
id	b1	vc	bc	d	f	total	y	t
2	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL
DROP TABLE t1;