You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by ji...@apache.org on 2022/04/18 09:44:04 UTC

[shardingsphere] branch master updated: `CREATE SHARDING ALGORITHM` syntax doc. (#16858)

This is an automated email from the ASF dual-hosted git repository.

jianglongtao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new 94d9c839a5c `CREATE SHARDING ALGORITHM` syntax doc. (#16858)
94d9c839a5c is described below

commit 94d9c839a5cf5f6de3010a8eb04f5710fa381b44
Author: lanchengx <52...@users.noreply.github.com>
AuthorDate: Mon Apr 18 17:43:57 2022 +0800

    `CREATE SHARDING ALGORITHM` syntax doc. (#16858)
    
    * DistSQL Documentation.
    
    * DistSQL Documentation.
    
    * Update create-sharding-table-rule.en.md
    
    * Update create-sharding-algorithm.en.md
---
 .../create-sharding-algorithm.cn.md                | 55 ++++++++++++++++++++++
 .../create-sharding-algorithm.en.md                | 55 ++++++++++++++++++++++
 .../create-sharding-table-rule.cn.md               |  7 +--
 .../create-sharding-table-rule.en.md               |  9 ++--
 .../reference/distsql/syntax/reserved-word.cn.md   |  8 +++-
 5 files changed, 126 insertions(+), 8 deletions(-)

diff --git a/docs/document/content/reference/distsql/syntax/rdl/rule-definition/create-sharding-algorithm.cn.md b/docs/document/content/reference/distsql/syntax/rdl/rule-definition/create-sharding-algorithm.cn.md
new file mode 100644
index 00000000000..9c75f8fa2e7
--- /dev/null
+++ b/docs/document/content/reference/distsql/syntax/rdl/rule-definition/create-sharding-algorithm.cn.md
@@ -0,0 +1,55 @@
++++
+title = "CREATE SHARDING ALGORITHM"
+weight = 2
++++
+
+## 描述
+
+`CREATE SHARDING ALGORITHM` 语法用于为当前所选的逻辑库添加分片算法
+
+### 语法定义
+
+```SQL
+CreateShardingAlgorithm ::=
+  'CREATE' 'SHARDING' 'ALGORITHM' shardingAlgorithmName '(' algorithmDefinition ')'
+
+algorithmDefinition ::=
+  'TYPE' '(' 'NAME' '=' algorithmType ( ',' 'PROPERTIES'  '(' propertyDefinition  ')' )?')'  
+
+propertyDefinition ::=
+  ( key  '=' value ) ( ',' key  '=' value )*
+
+shardingAlgorithmName ::=
+  identifier
+  
+algorithmType ::=
+  identifier
+```
+
+### 补充说明
+
+- `algorithmType` 为分片算法类型,详细的分片算法类型信息请参考[分片算法](/cn/user-manual/shardingsphere-jdbc/builtin-algorithm/sharding/)
+
+### 示例
+
+#### 1.创建分片算法
+
+```SQL
+-- 创建类型为 INLINE 的分片算法
+CREATE SHARDING ALGORITHM inline_algorithm (
+    TYPE(NAME=inline, PROPERTIES("algorithm-expression"="t_order_${user_id % 2}"))
+);
+
+-- 创建类型为 AUTO_INTERVAL 的分片算法
+CREATE SHARDING ALGORITHM interval_algorithm (
+    TYPE(NAME=auto_interval, PROPERTIES("datetime-lower"="2022-01-01 00:00:00", "datetime-upper"="2022-01-03 00:00:00", "sharding-seconds"="86400"))
+);
+```
+
+### 保留字
+
+    CREATE、SHARDING、ALGORITHM、TYPE、NAME、PROPERTIES
+
+### 相关链接
+- [保留字](/cn/reference/distsql/syntax/reserved-word/)
+
diff --git a/docs/document/content/reference/distsql/syntax/rdl/rule-definition/create-sharding-algorithm.en.md b/docs/document/content/reference/distsql/syntax/rdl/rule-definition/create-sharding-algorithm.en.md
new file mode 100644
index 00000000000..75636651ddb
--- /dev/null
+++ b/docs/document/content/reference/distsql/syntax/rdl/rule-definition/create-sharding-algorithm.en.md
@@ -0,0 +1,55 @@
++++
+title = "CREATE SHARDING ALGORITHM"
+weight = 2
++++
+
+## Description
+
+The `CREATE SHARDING ALGORITHM` syntax is used to create a sharding algorithm for the currently selected schema.
+
+### Syntax
+
+```SQL
+CreateShardingAlgorithm ::=
+  'CREATE' 'SHARDING' 'ALGORITHM' shardingAlgorithmName '(' algorithmDefinition ')'
+
+algorithmDefinition ::=
+  'TYPE' '(' 'NAME' '=' algorithmType ( ',' 'PROPERTIES'  '(' propertyDefinition  ')' )?')'  
+
+propertyDefinition ::=
+  ( key  '=' value ) ( ',' key  '=' value )*
+
+shardingAlgorithmName ::=
+  identifier
+  
+algorithmType ::=
+  identifier
+```
+
+### Supplement
+
+- `algorithmType` is the sharding algorithm type. For detailed sharding algorithm type information, please refer to [Sharding Algorithm](/en/user-manual/shardingsphere-jdbc/builtin-algorithm/sharding/)
+
+### Example
+
+#### 1.Create sharding algorithms
+
+```SQL
+-- create a sharding algorithm of type INLINE
+CREATE SHARDING ALGORITHM inline_algorithm (
+    TYPE(NAME=inline, PROPERTIES("algorithm-expression"="t_order_${user_id % 2}"))
+);
+
+-- create a sharding algorithm of type AUTO_INTERVAL
+CREATE SHARDING ALGORITHM interval_algorithm (
+    TYPE(NAME=auto_interval, PROPERTIES("datetime-lower"="2022-01-01 00:00:00", "datetime-upper"="2022-01-03 00:00:00", "sharding-seconds"="86400"))
+);
+```
+
+### Reserved word
+
+    CREATE、SHARDING、ALGORITHM、TYPE、NAME、PROPERTIES
+
+### Related links
+- [Reserved word](/cn/reference/distsql/syntax/reserved-word/)
+
diff --git a/docs/document/content/reference/distsql/syntax/rdl/rule-definition/create-sharding-table-rule.cn.md b/docs/document/content/reference/distsql/syntax/rdl/rule-definition/create-sharding-table-rule.cn.md
index ea362eeac95..d3b8d34e93d 100644
--- a/docs/document/content/reference/distsql/syntax/rdl/rule-definition/create-sharding-table-rule.cn.md
+++ b/docs/document/content/reference/distsql/syntax/rdl/rule-definition/create-sharding-table-rule.cn.md
@@ -26,9 +26,9 @@ keyGenerateStrategyDefinition ::=
   'KEY_GENERATE_STRATEGY' '(' 'COLUMN' '=' columnName ',' ( 'KEY_GENERATOR' '=' algorihtmName | algorithmDefinition ) ')' 
 
 algorithmDefinition ::=
-  ('SHARDING_ALGORITHM' '=' algorithmName | 'TYPE' '(' 'NAME' '=' algorithmType ( ',' 'PROPERTIES'  '(' propretyDefinition  ')' )?')'  )
+  ('SHARDING_ALGORITHM' '=' algorithmName | 'TYPE' '(' 'NAME' '=' algorithmType ( ',' 'PROPERTIES'  '(' propertyDefinition  ')' )?')'  )
 
-propretyDefinition ::=
+propertyDefinition ::=
     ( key  '=' value ) ( ',' key  '=' value )* 
 ```
 
@@ -42,7 +42,8 @@ propretyDefinition ::=
 - 当使用自动分片时:
     - `RESOURCES` 只能使用已经添加到当前逻辑库的资源,可通过枚举或 INLINE 表达式指定需要的资源
     - 只能使用自动分片算法,可参考[自动分片算法](/cn/user-manual/shardingsphere-jdbc/builtin-algorithm/sharding/#自动分片算法)
-- 自动生成的算法命名规则为  `tableName` _ `strategyType` _ `shardingAlgorithmType`
+- `algorithmType` 为分片算法类型,分片算法类型请参考[分片算法](/cn/user-manual/shardingsphere-jdbc/builtin-algorithm/sharding/)
+- 自动生成的算法命名规则为  `tableName` _ `strategyType` _ `algorithmType`
 - 自动生成的主键策略命名规则为 `tableName` _ `strategyType`
 - `KEY_GENERATE_STRATEGY` 用于指定主键生成策略,为可选项,关于主键生成策略可参考[分布式主键](/cn/user-manual/shardingsphere-jdbc/builtin-algorithm/keygen/)
 
diff --git a/docs/document/content/reference/distsql/syntax/rdl/rule-definition/create-sharding-table-rule.en.md b/docs/document/content/reference/distsql/syntax/rdl/rule-definition/create-sharding-table-rule.en.md
index e78c78ff54e..84c6e44bef6 100644
--- a/docs/document/content/reference/distsql/syntax/rdl/rule-definition/create-sharding-table-rule.en.md
+++ b/docs/document/content/reference/distsql/syntax/rdl/rule-definition/create-sharding-table-rule.en.md
@@ -26,9 +26,9 @@ keyGenerateStrategyDefinition ::=
   'KEY_GENERATE_STRATEGY' '(' 'COLUMN' '=' columnName ',' ( 'KEY_GENERATOR' '=' algorihtmName | algorithmDefinition ) ')' 
 
 algorithmDefinition ::=
-  ('SHARDING_ALGORITHM' '=' algorithmName | 'TYPE' '(' 'NAME' '=' algorithmType ( ',' 'PROPERTIES'  '(' propretyDefinition  ')' )?')'  )
+  ('SHARDING_ALGORITHM' '=' algorithmName | 'TYPE' '(' 'NAME' '=' algorithmType ( ',' 'PROPERTIES'  '(' propertyDefinition  ')' )?')'  )
 
-propretyDefinition ::=
+propertyDefinition ::=
     ( key  '=' value ) ( ',' key  '=' value )* 
 ```
 
@@ -38,10 +38,11 @@ propretyDefinition ::=
 - use standard sharding table rule
   - `DATANODES` can only use resources that have been added to the current schema, and can only use INLINE expressions to specify required resources    
   - `DATABASE_STRATEGY`, `TABLE_STRATEGY` are the database sharding strategy and the table sharding strategy, which are optional, and the default strategy is used when not configured  
-  - The attribute `TYPE` in `strategyDefinition` is used to specify the type of [sharding algorithm](/en/features/sharding/concept/sharding/#user-defined-sharding-algorithm), currently only supports `STANDARD`, `COMPLEX`. Using `COMPLEX` requires specifying multiple sharding columns with `SHARDING_COLUMNS`.
+  - The attribute `TYPE` in `strategyDefinition` is used to specify the type of [Sharding Algorithm](/en/features/sharding/concept/sharding/#user-defined-sharding-algorithm), currently only supports `STANDARD`, `COMPLEX`. Using `COMPLEX` requires specifying multiple sharding columns with `SHARDING_COLUMNS`.
 - use auto sharding table rule
     - `RESOURCES` can only use resources that have been added to the current schema, and the required resources can be specified by enumeration or INLINE expression
-    - Only auto sharding algorithm can be used, please refer to [auto sharding algorithm](/en/user-manual/shardingsphere-jdbc/builtin-algorithm/sharding/#auto-sharding-algorithm)    
+    - Only auto sharding algorithm can be used, please refer to [Auto Sharding Algorithm](/en/user-manual/shardingsphere-jdbc/builtin-algorithm/sharding/#auto-sharding-algorithm)    
+- `algorithmType` is the sharding algorithm type, please refer to [Sharding Algorithm](en/user-manual/shardingsphere-jdbc/builtin-algorithm/sharding)
 - The auto-generated algorithm naming rule is `tableName` _ `strategyType` _ `shardingAlgorithmType`
 - The auto-generated primary key strategy naming rule is `tableName` _ `strategyType`
 - `KEY_GENERATE_STRATEGY` is used to specify the primary key generation strategy, which is optional. For the primary key generation strategy, please refer to [Distributed Primary Key](/en/user-manual/shardingsphere-jdbc/builtin-algorithm/keygen/)
diff --git a/docs/document/content/reference/distsql/syntax/reserved-word.cn.md b/docs/document/content/reference/distsql/syntax/reserved-word.cn.md
index b0b1b1f7011..d71c9145fea 100644
--- a/docs/document/content/reference/distsql/syntax/reserved-word.cn.md
+++ b/docs/document/content/reference/distsql/syntax/reserved-word.cn.md
@@ -6,7 +6,13 @@ weight = 3
 ### 资源定义
 
 ```sql
-ADD, RESOURCE, HOST, PORT, DB, USER, PASSWORD, PROPERTIES, URL
+ADD, DROP, RESOURCE, IF, EXISTS, HOST, PORT, DB, USER, PASSWORD, PROPERTIES, URL
+```
+### 规则定义
+
+#### SHARDING
+```sql
+    CREATE, SHARDING, TABLE, RULE, ALGORITHM, DATANODES, DATABASE_STRATEGY, TABLE_STRATEGY, KEY_GENERATE_STRATEGY, RESOURCES, SHARDING_COLUMN, TYPE, SHARDING_COLUMN, KEY_GENERATOR, SHARDING_ALGORITHM, COLUMN, NAME, PROPERTIES
 ```
 
 ### 补充说明