File: vcol_partition_innodb.result

package info (click to toggle)
mariadb-10.0 10.0.32-0%2Bdeb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 476,064 kB
  • sloc: cpp: 1,400,131; ansic: 832,140; perl: 54,391; sh: 41,304; pascal: 32,365; yacc: 14,921; xml: 5,257; sql: 4,667; cs: 4,647; makefile: 4,555; ruby: 4,465; python: 2,292; lex: 1,427; java: 941; asm: 295; awk: 54; php: 22; sed: 16
file content (80 lines) | stat: -rw-r--r-- 2,296 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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
SET @@session.storage_engine = 'InnoDB';
drop table if exists t1;
# Case 1. Partitioning by RANGE based on a non-stored virtual column.
CREATE TABLE t1 (
a DATE NOT NULL,
b int as (year(a))
)
PARTITION BY RANGE( b ) (
PARTITION p0 VALUES LESS THAN (2006),
PARTITION p2 VALUES LESS THAN (2008)
);
insert into t1 values ('2006-01-01',default);
insert into t1 values ('2007-01-01',default);
insert into t1 values ('2005-01-01',default);
select * from t1;
a	b
2005-01-01	2005
2006-01-01	2006
2007-01-01	2007
select partition_name,table_rows,data_length from information_schema.partitions where table_name = 't1';
partition_name	table_rows	data_length
p0	1	16384
p2	2	16384
# Modify the expression of virtual column b
ALTER TABLE t1 modify b int as (year(a)-1);
select * from t1;
a	b
2005-01-01	2004
2006-01-01	2005
2007-01-01	2006
select partition_name,table_rows,data_length from information_schema.partitions where table_name = 't1';
partition_name	table_rows	data_length
p0	2	16384
p2	1	16384
drop table t1;
# Case 2. Partitioning by LIST based on a stored virtual column.
CREATE TABLE t1 (a int, b int as (a % 3 ) persistent)
PARTITION BY LIST (a+1)
(PARTITION p1 VALUES IN (1), PARTITION p2 VALUES IN (2));
insert into t1 values (1,default);
select partition_name,table_rows,data_length from information_schema.partitions where table_name = 't1';
partition_name	table_rows	data_length
p1	0	16384
p2	1	16384
select * from t1;
a	b
1	1
select * from t1;
a	b
1	1
drop table t1;
# Case 3. Partitioning by HASH based on a non-stored virtual column.
CREATE TABLE t1 (
a DATE NOT NULL,
b int as (year(a))
)
PARTITION BY HASH( b % 3 ) PARTITIONS 3;
insert into t1 values ('2005-01-01',default);
insert into t1 values ('2006-01-01',default);
select * from t1;
a	b
2005-01-01	2005
2006-01-01	2006
select partition_name,table_rows,data_length from information_schema.partitions where table_name = 't1';
partition_name	table_rows	data_length
p0	0	16384
p1	1	16384
p2	1	16384
# Modify the expression of virtual column b
ALTER TABLE t1 modify b int as (year(a)-1);
select * from t1;
a	b
2005-01-01	2004
2006-01-01	2005
select partition_name,table_rows,data_length from information_schema.partitions where table_name = 't1';
partition_name	table_rows	data_length
p0	1	16384
p1	1	16384
p2	0	16384
drop table t1;