diff --git a/product/en/docs-mogdb/v2.1/reference-guide/sql-syntax/62.1-CREATE-TABLE-SUBPARTITION.md b/product/en/docs-mogdb/v2.1/reference-guide/sql-syntax/62.1-CREATE-TABLE-SUBPARTITION.md index 8083c393aa8c84378abf2e753f95640fb7a86e51..32a6223979ae137e4b55492198cca28edaf5462d 100644 --- a/product/en/docs-mogdb/v2.1/reference-guide/sql-syntax/62.1-CREATE-TABLE-SUBPARTITION.md +++ b/product/en/docs-mogdb/v2.1/reference-guide/sql-syntax/62.1-CREATE-TABLE-SUBPARTITION.md @@ -13,16 +13,16 @@ Creates a level-2 partitioned table. A partitioned table is a logical table that The partitioning solution of a level-2 partitioned table is a combination of the partitioning solutions of two level-1 partitions. For details about the partitioning solution of a level-1 partitioned table, see [CREATE TABLE PARTITION](62-CREATE-TABLE-PARTITION). -Common combination solutions for level-2 partitioned tables include range-range partitioning, range-list partitioning, range-hash partitioning, list-range partitioning, list-list partitioning, list-hash partitioning, hash-range partitioning, hash-list partitioning, and hash-hash partitioning. Currently, level-2 partitioned tables can only be row-store tables. +Common combination solutions for level-2 partitioned tables include range-range partitioning, range-list partitioning, range-hash partitioning, list-range partitioning, list-list partitioning, list-hash partitioning. Currently, level-2 partitioned tables can only be row-store tables. ## Precautions - A level-2 partitioned table has two partition keys, and each partition key supports only one column. - If the constraint key of the unique constraint and primary key constraint contains all partition keys, a local index is created for the constraints. Otherwise, a global index is created. -- The number of level-2 partitions (leaf nodes) in a level-2 partitioned table cannot exceed 1048575. There is no limit on the number of level-1 partitions, but there must be at least one level-2 partition under a level-1 partition. +- The number of level-2 partitions (leaf nodes) in a level-2 partitioned table cannot exceed 1048575. The number of level-1 partitions cannot exceed 64, and there must be at least one level-2 partition under a level-1 partition. - Level-2 partitioned tables support only row store and do not support column-store, segment-page, or hash bucket. - UPSERT and MERGE INTO into are not supported. -- When specifying a partition for query, for example, **select \* from tablename partition/subpartition** (*partitionname*), ensure that the keywords **partition** and **subpartition** are correct. If they are incorrect, no error is reported during the query. In this case, the query is performed based on the table alias. +- When specifying a partition for query, for example, **select \* from tablename partition/subpartition** (*partitionname*), ensure that the keywords **partition** and **subpartition** are correct. If they are incorrect, an error is reported during the query. In this case, the query is performed based on the table alias. - Level-2 partitioned tables do not support the subpartition for (values) query, for example, **select \* from tablename subpartition for** (*values*). - Does not support secret database, ledger database and row-level access control. - Does not support subpartitions under INTERVAL partitions. @@ -39,7 +39,7 @@ CreateTableSubpartition ::= CREATE TABLE [ IF NOT EXISTS ] subpartition_table_na [ WITH ( {storage_parameter = value} [, ... ] ) ] [ COMPRESS | NOCOMPRESS ] [ TABLESPACE tablespace_name ] -PARTITION BY {RANGE | LIST | HASH} (partition_key) SUBPARTITION BY {RANGE | LIST | HASH} (subpartition_key) +PARTITION BY {RANGE | LIST} (partition_key) SUBPARTITION BY {RANGE | LIST | HASH} (subpartition_key) ( PARTITION partition_name1 [ VALUES LESS THAN (val1) | VALUES (val1[, ...]) ] [ TABLESPACE tablespace ] ( @@ -319,7 +319,7 @@ The secondary partition table does not support this function temporarily. 201902 | 1 | 1 | 1 201902 | 1 | 1 | 1 (6 rows) - + drop table list_list; CREATE TABLE list_hash ( @@ -357,7 +357,7 @@ The secondary partition table does not support this function temporarily. 201902 | 3 | 1 | 1 201902 | 1 | 1 | 1 (6 rows) - + drop table list_hash; CREATE TABLE list_range ( @@ -395,7 +395,7 @@ The secondary partition table does not support this function temporarily. 201902 | 2 | 1 | 1 201902 | 3 | 1 | 1 (5 rows) - + drop table list_range; CREATE TABLE range_list ( @@ -433,7 +433,7 @@ The secondary partition table does not support this function temporarily. 201903 | 2 | 1 | 1 201903 | 1 | 1 | 1 (6 rows) - + drop table range_list; CREATE TABLE range_hash ( @@ -471,7 +471,7 @@ The secondary partition table does not support this function temporarily. 201903 | 2 | 1 | 1 201903 | 1 | 1 | 1 (6 rows) - + drop table range_hash; CREATE TABLE range_range ( @@ -509,122 +509,10 @@ The secondary partition table does not support this function temporarily. 201903 | 2 | 1 | 1 201903 | 2 | 1 | 1 (6 rows) - + drop table range_range; - CREATE TABLE hash_list - ( - month_code VARCHAR2 ( 30 ) NOT NULL , - dept_code VARCHAR2 ( 30 ) NOT NULL , - user_no VARCHAR2 ( 30 ) NOT NULL , - sales_amt int - ) - PARTITION BY hash (month_code) SUBPARTITION BY LIST (dept_code) - ( - PARTITION p_201901 - ( - SUBPARTITION p_201901_a VALUES ( '1' ), - SUBPARTITION p_201901_b VALUES ( '2' ) - ), - PARTITION p_201902 - ( - SUBPARTITION p_201902_a VALUES ( '1' ), - SUBPARTITION p_201902_b VALUES ( '2' ) - ) - ); - insert into hash_list values('201901', '1', '1', 1); - insert into hash_list values('201901', '2', '1', 1); - insert into hash_list values('201901', '1', '1', 1); - insert into hash_list values('201903', '2', '1', 1); - insert into hash_list values('201903', '1', '1', 1); - insert into hash_list values('201903', '2', '1', 1); - select * from hash_list; - month_code | dept_code | user_no | sales_amt - ------------+-----------+---------+----------- - 201903 | 2 | 1 | 1 - 201903 | 2 | 1 | 1 - 201903 | 1 | 1 | 1 - 201901 | 2 | 1 | 1 - 201901 | 1 | 1 | 1 - 201901 | 1 | 1 | 1 - (6 rows) - - drop table hash_list; - CREATE TABLE hash_hash - ( - month_code VARCHAR2 ( 30 ) NOT NULL , - dept_code VARCHAR2 ( 30 ) NOT NULL , - user_no VARCHAR2 ( 30 ) NOT NULL , - sales_amt int - ) - PARTITION BY hash (month_code) SUBPARTITION BY hash (dept_code) - ( - PARTITION p_201901 - ( - SUBPARTITION p_201901_a, - SUBPARTITION p_201901_b - ), - PARTITION p_201902 - ( - SUBPARTITION p_201902_a, - SUBPARTITION p_201902_b - ) - ); - insert into hash_hash values('201901', '1', '1', 1); - insert into hash_hash values('201901', '2', '1', 1); - insert into hash_hash values('201901', '1', '1', 1); - insert into hash_hash values('201903', '2', '1', 1); - insert into hash_hash values('201903', '1', '1', 1); - insert into hash_hash values('201903', '2', '1', 1); - select * from hash_hash; - month_code | dept_code | user_no | sales_amt - ------------+-----------+---------+----------- - 201903 | 2 | 1 | 1 - 201903 | 2 | 1 | 1 - 201903 | 1 | 1 | 1 - 201901 | 2 | 1 | 1 - 201901 | 1 | 1 | 1 - 201901 | 1 | 1 | 1 - (6 rows) - - drop table hash_hash; - CREATE TABLE hash_range - ( - month_code VARCHAR2 ( 30 ) NOT NULL , - dept_code VARCHAR2 ( 30 ) NOT NULL , - user_no VARCHAR2 ( 30 ) NOT NULL , - sales_amt int - ) - PARTITION BY hash (month_code) SUBPARTITION BY range (dept_code) - ( - PARTITION p_201901 - ( - SUBPARTITION p_201901_a VALUES LESS THAN ( '2' ), - SUBPARTITION p_201901_b VALUES LESS THAN ( '3' ) - ), - PARTITION p_201902 - ( - SUBPARTITION p_201902_a VALUES LESS THAN ( '2' ), - SUBPARTITION p_201902_b VALUES LESS THAN ( '3' ) - ) - ); - insert into hash_range values('201901', '1', '1', 1); - insert into hash_range values('201901', '2', '1', 1); - insert into hash_range values('201901', '1', '1', 1); - insert into hash_range values('201903', '2', '1', 1); - insert into hash_range values('201903', '1', '1', 1); - insert into hash_range values('201903', '2', '1', 1); - select * from hash_range; - month_code | dept_code | user_no | sales_amt - ------------+-----------+---------+----------- - 201903 | 1 | 1 | 1 - 201903 | 2 | 1 | 1 - 201903 | 2 | 1 | 1 - 201901 | 1 | 1 | 1 - 201901 | 1 | 1 | 1 - 201901 | 2 | 1 | 1 - (6 rows) ``` - + - Example 2: Truncate a level-2 partitioned table. ```sql diff --git a/product/zh/docs-mogdb/v2.1/reference-guide/sql-syntax/62.1-CREATE-TABLE-SUBPARTITION.md b/product/zh/docs-mogdb/v2.1/reference-guide/sql-syntax/62.1-CREATE-TABLE-SUBPARTITION.md index e3f5649bfd873faa16e34b4c5242e9aa549db43e..b84b77c8258e300b096b97c52fbecf89b4199884 100644 --- a/product/zh/docs-mogdb/v2.1/reference-guide/sql-syntax/62.1-CREATE-TABLE-SUBPARTITION.md +++ b/product/zh/docs-mogdb/v2.1/reference-guide/sql-syntax/62.1-CREATE-TABLE-SUBPARTITION.md @@ -13,16 +13,16 @@ date: 2021-11-01 二级分区表的分区方案是由两个一级分区的分区方案组合而来的,一级分区的分区方案详见章节[CREATE TABLE PARTITION](62-CREATE-TABLE-PARTITION)。 -常见的二级分区表组合方案有Range-Range分区、Range-List分区、Range-Hash分区、List-Range分区、List-List分区、List-Hash分区、Hash-Range分区、Hash-List分区、Hash-Hash分区等。目前二级分区仅支持行存表。 +常见的二级分区表组合方案有Range-Range分区、Range-List分区、Range-Hash分区、List-Range分区、List-List分区、List-Hash分区。目前二级分区仅支持行存表。 ## 注意事项 - 二级分区表有两个分区键,每个分区键只能支持1列。 - 唯一约束和主键约束的约束键包含所有分区键将为约束创建LOCAL索引,否则创建GLOBAL索引。 -- 二级分区表的二级分区(叶子节点)个数不能超过1048575个,一级分区无限制,但一级分区下面至少有一个二级分区。 +- 二级分区表的二级分区(叶子节点)个数不能超过1048575个,一级分区最多64个,一级分区下面至少有一个二级分区。 - 二级分区表只支持行存,不支持列存、段页式、hashbucket。 - 不支持Upsert、Merge into。 -- 指定分区查询时,如select * from tablename partition/subpartition (partitionname),关键字partition和subpartition注意不要写错。如果写错,查询不会报错,这时查询会变为对表起别名进行查询。 +- 指定分区查询时,如select * from tablename partition/subpartition (partitionname),关键字partition和subpartition注意不要写错。如果写错,查询会报错,这时查询会变为对表起别名进行查询。 - 不支持对二级分区 subpartition for (values)查询。如select * from tablename subpartition for (values)。 - 不支持密态数据库、账本数据库和行级访问控制。 - 不支持INTERVAL分区下的子分区。 @@ -39,7 +39,7 @@ CreateTableSubpartition ::= CREATE TABLE [ IF NOT EXISTS ] subpartition_table_na [ WITH ( {storage_parameter = value} [, ... ] ) ] [ COMPRESS | NOCOMPRESS ] [ TABLESPACE tablespace_name ] -PARTITION BY {RANGE | LIST | HASH} (partition_key) SUBPARTITION BY {RANGE | LIST | HASH} (subpartition_key) +PARTITION BY {RANGE | LIST} (partition_key) SUBPARTITION BY {RANGE | LIST | HASH} (subpartition_key) ( PARTITION partition_name1 [ VALUES LESS THAN (val1) | VALUES (val1[, ...]) ] [ TABLESPACE tablespace ] ( @@ -325,7 +325,7 @@ PARTITION BY {RANGE | LIST | HASH} (partition_key) SUBPARTITION BY {RANGE | LIST 201902 | 1 | 1 | 1 201902 | 1 | 1 | 1 (6 rows) - + drop table list_list; CREATE TABLE list_hash ( @@ -363,7 +363,7 @@ PARTITION BY {RANGE | LIST | HASH} (partition_key) SUBPARTITION BY {RANGE | LIST 201902 | 3 | 1 | 1 201902 | 1 | 1 | 1 (6 rows) - + drop table list_hash; CREATE TABLE list_range ( @@ -401,7 +401,7 @@ PARTITION BY {RANGE | LIST | HASH} (partition_key) SUBPARTITION BY {RANGE | LIST 201902 | 2 | 1 | 1 201902 | 3 | 1 | 1 (5 rows) - + drop table list_range; CREATE TABLE range_list ( @@ -439,7 +439,7 @@ PARTITION BY {RANGE | LIST | HASH} (partition_key) SUBPARTITION BY {RANGE | LIST 201903 | 2 | 1 | 1 201903 | 1 | 1 | 1 (6 rows) - + drop table range_list; CREATE TABLE range_hash ( @@ -477,7 +477,7 @@ PARTITION BY {RANGE | LIST | HASH} (partition_key) SUBPARTITION BY {RANGE | LIST 201903 | 2 | 1 | 1 201903 | 1 | 1 | 1 (6 rows) - + drop table range_hash; CREATE TABLE range_range ( @@ -515,122 +515,10 @@ PARTITION BY {RANGE | LIST | HASH} (partition_key) SUBPARTITION BY {RANGE | LIST 201903 | 2 | 1 | 1 201903 | 2 | 1 | 1 (6 rows) - + drop table range_range; - CREATE TABLE hash_list - ( - month_code VARCHAR2 ( 30 ) NOT NULL , - dept_code VARCHAR2 ( 30 ) NOT NULL , - user_no VARCHAR2 ( 30 ) NOT NULL , - sales_amt int - ) - PARTITION BY hash (month_code) SUBPARTITION BY LIST (dept_code) - ( - PARTITION p_201901 - ( - SUBPARTITION p_201901_a VALUES ( '1' ), - SUBPARTITION p_201901_b VALUES ( '2' ) - ), - PARTITION p_201902 - ( - SUBPARTITION p_201902_a VALUES ( '1' ), - SUBPARTITION p_201902_b VALUES ( '2' ) - ) - ); - insert into hash_list values('201901', '1', '1', 1); - insert into hash_list values('201901', '2', '1', 1); - insert into hash_list values('201901', '1', '1', 1); - insert into hash_list values('201903', '2', '1', 1); - insert into hash_list values('201903', '1', '1', 1); - insert into hash_list values('201903', '2', '1', 1); - select * from hash_list; - month_code | dept_code | user_no | sales_amt - ------------+-----------+---------+----------- - 201903 | 2 | 1 | 1 - 201903 | 2 | 1 | 1 - 201903 | 1 | 1 | 1 - 201901 | 2 | 1 | 1 - 201901 | 1 | 1 | 1 - 201901 | 1 | 1 | 1 - (6 rows) - - drop table hash_list; - CREATE TABLE hash_hash - ( - month_code VARCHAR2 ( 30 ) NOT NULL , - dept_code VARCHAR2 ( 30 ) NOT NULL , - user_no VARCHAR2 ( 30 ) NOT NULL , - sales_amt int - ) - PARTITION BY hash (month_code) SUBPARTITION BY hash (dept_code) - ( - PARTITION p_201901 - ( - SUBPARTITION p_201901_a, - SUBPARTITION p_201901_b - ), - PARTITION p_201902 - ( - SUBPARTITION p_201902_a, - SUBPARTITION p_201902_b - ) - ); - insert into hash_hash values('201901', '1', '1', 1); - insert into hash_hash values('201901', '2', '1', 1); - insert into hash_hash values('201901', '1', '1', 1); - insert into hash_hash values('201903', '2', '1', 1); - insert into hash_hash values('201903', '1', '1', 1); - insert into hash_hash values('201903', '2', '1', 1); - select * from hash_hash; - month_code | dept_code | user_no | sales_amt - ------------+-----------+---------+----------- - 201903 | 2 | 1 | 1 - 201903 | 2 | 1 | 1 - 201903 | 1 | 1 | 1 - 201901 | 2 | 1 | 1 - 201901 | 1 | 1 | 1 - 201901 | 1 | 1 | 1 - (6 rows) - - drop table hash_hash; - CREATE TABLE hash_range - ( - month_code VARCHAR2 ( 30 ) NOT NULL , - dept_code VARCHAR2 ( 30 ) NOT NULL , - user_no VARCHAR2 ( 30 ) NOT NULL , - sales_amt int - ) - PARTITION BY hash (month_code) SUBPARTITION BY range (dept_code) - ( - PARTITION p_201901 - ( - SUBPARTITION p_201901_a VALUES LESS THAN ( '2' ), - SUBPARTITION p_201901_b VALUES LESS THAN ( '3' ) - ), - PARTITION p_201902 - ( - SUBPARTITION p_201902_a VALUES LESS THAN ( '2' ), - SUBPARTITION p_201902_b VALUES LESS THAN ( '3' ) - ) - ); - insert into hash_range values('201901', '1', '1', 1); - insert into hash_range values('201901', '2', '1', 1); - insert into hash_range values('201901', '1', '1', 1); - insert into hash_range values('201903', '2', '1', 1); - insert into hash_range values('201903', '1', '1', 1); - insert into hash_range values('201903', '2', '1', 1); - select * from hash_range; - month_code | dept_code | user_no | sales_amt - ------------+-----------+---------+----------- - 201903 | 1 | 1 | 1 - 201903 | 2 | 1 | 1 - 201903 | 2 | 1 | 1 - 201901 | 1 | 1 | 1 - 201901 | 1 | 1 | 1 - 201901 | 2 | 1 | 1 - (6 rows) ``` - + - 示例2:对二级分区表进行truncate操作 ```sql @@ -670,7 +558,7 @@ PARTITION BY {RANGE | LIST | HASH} (partition_key) SUBPARTITION BY {RANGE | LIST 201902 | 1 | 1 | 1 201902 | 1 | 1 | 1 (6 rows) - + select * from list_list partition (p_201901); month_code | dept_code | user_no | sales_amt ------------+-----------+---------+----------- @@ -678,13 +566,13 @@ PARTITION BY {RANGE | LIST | HASH} (partition_key) SUBPARTITION BY {RANGE | LIST 201902 | 1 | 1 | 1 201902 | 1 | 1 | 1 (3 rows) - + alter table list_list truncate partition p_201901; select * from list_list partition (p_201901); month_code | dept_code | user_no | sales_amt ------------+-----------+---------+----------- (0 rows) - + select * from list_list partition (p_201902); month_code | dept_code | user_no | sales_amt ------------+-----------+---------+----------- @@ -692,18 +580,18 @@ PARTITION BY {RANGE | LIST | HASH} (partition_key) SUBPARTITION BY {RANGE | LIST 201903 | 2 | 1 | 1 201903 | 1 | 1 | 1 (3 rows) - + alter table list_list truncate partition p_201902; select * from list_list partition (p_201902); month_code | dept_code | user_no | sales_amt ------------+-----------+---------+----------- (0 rows) - + select * from list_list; month_code | dept_code | user_no | sales_amt ------------+-----------+---------+----------- (0 rows) - + insert into list_list values('201902', '1', '1', 1); insert into list_list values('201902', '2', '1', 1); insert into list_list values('201902', '1', '1', 1); @@ -716,59 +604,58 @@ PARTITION BY {RANGE | LIST | HASH} (partition_key) SUBPARTITION BY {RANGE | LIST 201902 | 1 | 1 | 1 201902 | 1 | 1 | 1 (2 rows) - + alter table list_list truncate subpartition p_201901_a; select * from list_list subpartition (p_201901_a); month_code | dept_code | user_no | sales_amt ------------+-----------+---------+----------- (0 rows) - + select * from list_list subpartition (p_201901_b); month_code | dept_code | user_no | sales_amt ------------+-----------+---------+----------- 201902 | 2 | 1 | 1 (1 row) - + alter table list_list truncate subpartition p_201901_b; select * from list_list subpartition (p_201901_b); month_code | dept_code | user_no | sales_amt ------------+-----------+---------+----------- (0 rows) - + select * from list_list subpartition (p_201902_a); month_code | dept_code | user_no | sales_amt ------------+-----------+---------+----------- 201903 | 1 | 1 | 1 (1 row) - + alter table list_list truncate subpartition p_201902_a; select * from list_list subpartition (p_201902_a); month_code | dept_code | user_no | sales_amt ------------+-----------+---------+----------- (0 rows) - + select * from list_list subpartition (p_201902_b); month_code | dept_code | user_no | sales_amt ------------+-----------+---------+----------- 201903 | 2 | 1 | 1 201903 | 2 | 1 | 1 (2 rows) - + alter table list_list truncate subpartition p_201902_b; select * from list_list subpartition (p_201902_b); month_code | dept_code | user_no | sales_amt ------------+-----------+---------+----------- (0 rows) - + select * from list_list; month_code | dept_code | user_no | sales_amt ------------+-----------+---------+----------- (0 rows) - + drop table list_list; - ``` - + - 示例3:对二级分区表进行split操作 ```sql