mirror of
https://github.com/MariaDB/server.git
synced 2025-01-20 14:02:32 +01:00
114 lines
2.4 KiB
Text
114 lines
2.4 KiB
Text
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);
|
|
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;
|
|
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,
|
|
PRIMARY KEY (`b`),
|
|
UNIQUE KEY `a` (`a`)
|
|
) 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)
|
|
drop table t1;
|