CREATE TABLE student_range ( sno NUMERIC(4,0), sname CHARACTER VARYING(20 char), gender CHARACTER VARYING(20 char), birthday date, address CHARACTER VARYING(128 char) ) PARTITION BY RANGE (birthday); CREATE TABLE student_range1 PARTITION OF student_range FOR VALUES FROM ('2024-01-01') TO ('2024-03-01'); CREATE TABLE student_range2 PARTITION OF student_range FOR VALUES FROM ('2024-03-02') TO ('2024-05-01'); CREATE TABLE student_range3 PARTITION OF student_range FOR VALUES FROM ('2024-05-02') TO ('2024-07-01'); CREATE TABLE student_range4 PARTITION OF student_range FOR VALUES FROM ('2024-07-02') TO ('2024-09-01'); CREATE TABLE student_range5 PARTITION OF student_range FOR VALUES FROM ('2024-09-02') TO ('2024-11-01'); CREATE TABLE student_range6 PARTITION OF student_range FOR VALUES FROM ('2024-11-02') TO ('2025-01-01'); INSERT INTO student_range values(1,'tom',1,'2024-04-25','tianjin'); |
EXPLAIN SELECT * FROM student_range; |
EXPLAIN SELECT * FROM student_range WHERE birthday BETWEEN '2024-03-30' AND '2024-04-30'; |
CREATE TABLE student_list ( sno NUMERIC(4,0), sname CHARACTER VARYING(20 char), gender CHARACTER VARYING(20 char), birthday date, address CHARACTER VARYING(128 char) ) PARTITION BY LIST (address); CREATE TABLE student_list1 PARTITION OF student_list FOR VALUES IN ('tianjin'); CREATE TABLE student_list2 PARTITION OF student_list FOR VALUES IN ('beijing'); CREATE TABLE student_list3 PARTITION OF student_list FOR VALUES IN ('shanghai'); CREATE TABLE student_list4 PARTITION OF student_list FOR VALUES IN ('chongqin'); INSERT INTO student_list values(1,'tom',1,'2024-04-25','tianjin'); |
EXPLAIN SELECT * FROM student_list; |
EXPLAIN SELECT * FROM student_list WHERE address = 'tianjin'; |
CREATE TABLE student_hash ( sno NUMERIC(4,0), sname CHARACTER VARYING(20 char), gender CHARACTER VARYING(20 char), birthday date, address CHARACTER VARYING(128 char) ) PARTITION BY HASH (sno); CREATE TABLE student_hash1 PARTITION OF student_hash FOR VALUES WITH (MODULUS 4, REMAINDER 0); CREATE TABLE student_hash2 PARTITION OF student_hash FOR VALUES WITH (MODULUS 4, REMAINDER 1); CREATE TABLE student_hash3 PARTITION OF student_hash FOR VALUES WITH (MODULUS 4, REMAINDER 2); CREATE TABLE student_hash4 PARTITION OF student_hash FOR VALUES WITH (MODULUS 4, REMAINDER 3); INSERT INTO student_hash values(1,'tom1',1,'2024-04-25','tianjin'); INSERT INTO student_hash values(2,'tom2',1,'2024-04-25','tianjin'); INSERT INTO student_hash values(3,'tom3',1,'2024-04-25','tianjin'); INSERT INTO student_hash values(4,'tom4',1,'2024-04-25','tianjin'); |
EXPLAIN SELECT * FROM student_hash; |
EXPLAIN SELECT * FROM student_hash WHERE sno = 2; |
欢迎光临 ToB企服应用市场:ToB评测及商务社交产业平台 (https://dis.qidao123.com/) | Powered by Discuz! X3.4 |