From cd55ae9a8f83c994f0c14b66eced4bcaca2abedf Mon Sep 17 00:00:00 2001 From: Amber1990Zhang <42762957+Amber1990Zhang@users.noreply.github.com> Date: Mon, 9 Dec 2019 16:48:26 +0800 Subject: [PATCH 1/5] add if not exist --- .../create-space-syntax.md | 12 +++++++++--- .../create-tag-edge-syntax.md | 8 +++++++- .../create-space-syntax.md | 12 +++++++++--- .../create-tag-edge-syntax.md | 8 +++++++- 4 files changed, 32 insertions(+), 8 deletions(-) diff --git a/docs/manual-CN/2.query-language/4.statement-syntax/1.data-definition-statements/create-space-syntax.md b/docs/manual-CN/2.query-language/4.statement-syntax/1.data-definition-statements/create-space-syntax.md index 04e5b51d791..a54a77a1c8f 100644 --- a/docs/manual-CN/2.query-language/4.statement-syntax/1.data-definition-statements/create-space-syntax.md +++ b/docs/manual-CN/2.query-language/4.statement-syntax/1.data-definition-statements/create-space-syntax.md @@ -1,7 +1,7 @@ # CREATE SPACE 语法 ```ngql -CREATE SPACE space_name +CREATE SPACE (IF NOT EXIST) space_name (space_option,...) space_option: @@ -10,13 +10,19 @@ space_option: 以上语句用于创建一个新的图空间。不同的图空间是物理隔离的。 +## IF NOT EXIST + +创建图空间新增 `IF NOT EXIST` 关键字,这个关键字会自动检测对应的图空间是否存在,如果不存在则创建新的,如果存在则直接返回。 + +**注意:** 这里判断图空间是否存在只是比较图空间的名字(不包括属性)。 + ## Space Name 图空间名 * **space_name** 图空间的名称在集群中标明了一个唯一的空间。命名规则详见 [Schema Object Names](../../3.language-structure/schema-object-names.md) -### Space Options 图空间选项 +## Space Options 图空间选项 在创建图空间的时候,可以传入自定义选项。选项名称 _option_name_ 可以是以下任何一个: @@ -30,7 +36,7 @@ space_option: 如果没有自定义选项,**Nebula Graph** 会使用默认的值(partition_number 和 replica_factor)来创建图空间。 -### 示例 +## 示例 ```ngql nebula> CREATE SPACE my_space_1; -- 使用默认选项创建图空间 diff --git a/docs/manual-CN/2.query-language/4.statement-syntax/1.data-definition-statements/create-tag-edge-syntax.md b/docs/manual-CN/2.query-language/4.statement-syntax/1.data-definition-statements/create-tag-edge-syntax.md index fda310be0bc..54a9309da69 100644 --- a/docs/manual-CN/2.query-language/4.statement-syntax/1.data-definition-statements/create-tag-edge-syntax.md +++ b/docs/manual-CN/2.query-language/4.statement-syntax/1.data-definition-statements/create-tag-edge-syntax.md @@ -1,7 +1,7 @@ # CREATE TAG / EDGE 语法 ```ngql -CREATE {TAG | EDGE} tag_name|edge_name +CREATE {TAG | EDGE} (IF NOT EXIST) tag_name|edge_name (create_definition, ...) [tag_edge_options] @@ -20,6 +20,12 @@ option: `CREATE TAG/EDGE` 语法有一些特点,在如下分块中将对这些特点进行讨论: +## IF NOT EXIST + +创建 tag 或 edge 新增 `IF NOT EXIST` 关键字,这个关键字会自动检测对应的 tag 或 edge 是否存在,如果不存在则创建新的,如果存在则直接返回。 + +**注意:** 这里判断 tag 或 edge 是否存在只是比较 tag 或 edge 的名字(不包括属性)。 + ## Tag 名称和 Edge Type 名称 * **tag_name 和 edge_name** diff --git a/docs/manual-EN/2.query-language/4.statement-syntax/1.data-definition-statements/create-space-syntax.md b/docs/manual-EN/2.query-language/4.statement-syntax/1.data-definition-statements/create-space-syntax.md index 750cf3435c6..8e25ed60ce1 100644 --- a/docs/manual-EN/2.query-language/4.statement-syntax/1.data-definition-statements/create-space-syntax.md +++ b/docs/manual-EN/2.query-language/4.statement-syntax/1.data-definition-statements/create-space-syntax.md @@ -1,7 +1,7 @@ # Create Space Syntax ```ngql -CREATE SPACE space_name +CREATE SPACE (IF NOT EXIST) space_name (space_option,...) space_option: @@ -10,13 +10,19 @@ space_option: This statement creates a new space with the given name. SPACE is a region that provides physically isolated graphs in **Nebula Graph**. An error occurs if the database exists. +## IF NOT EXIST + +We added `If NOT EXIST` keyword for creating spaces. This keyword automatically detects if the corresponding space exists. If it does not exist, a new one is created. Otherwise, no space is created. + +**Note:** The space existence detection here only compares the space name (excluding properties). + ## Space Name * **space_name** The name uniquely identifies the space in a cluster. The rules for the naming are given in [Schema Object Names](../../3.language-structure/schema-object-names.md) -### Space Options +## Space Options When creating a space, options can be given. An _option_name_ can be any of the following: @@ -30,7 +36,7 @@ When creating a space, options can be given. An _option_name_ can be any of the However, if no option is given, **Nebula Graph** will create the space with the default partition number and replica factor. -### Example +## Example ```ngql nebula> CREATE SPACE my_space_1; -- create space with default partition number and replica factor diff --git a/docs/manual-EN/2.query-language/4.statement-syntax/1.data-definition-statements/create-tag-edge-syntax.md b/docs/manual-EN/2.query-language/4.statement-syntax/1.data-definition-statements/create-tag-edge-syntax.md index d3c7ea1ba52..a2ce284ac43 100644 --- a/docs/manual-EN/2.query-language/4.statement-syntax/1.data-definition-statements/create-tag-edge-syntax.md +++ b/docs/manual-EN/2.query-language/4.statement-syntax/1.data-definition-statements/create-tag-edge-syntax.md @@ -1,7 +1,7 @@ # Create TAG / EDGE Syntax ```ngql -CREATE {TAG | EDGE} | +CREATE {TAG | EDGE} (IF NOT EXIST) | (, ...) [tag_edge_options] @@ -21,6 +21,12 @@ CREATE {TAG | EDGE} | The features of this syntax are described in the following sections: +## IF NOT EXIST + +We added `If NOT EXIST` keyword for creating tags or edges. This keyword automatically detects if the corresponding tag or edge exists. If it does not exist, a new one is created. Otherwise, no tag or edge is created. + +**Note:** The tag or edge existence detection here only compares the tag or edge name (excluding properties). + ## Tag Name and Edge Type Name * **tag_name and edge_name** From ac2c5f0d8403297cd80f772ea4c2961df2ebb6fd Mon Sep 17 00:00:00 2001 From: Amber1990Zhang <42762957+Amber1990Zhang@users.noreply.github.com> Date: Tue, 10 Dec 2019 11:06:51 +0800 Subject: [PATCH 2/5] comments --- .../create-space-syntax.md | 7 ++----- .../create-tag-edge-syntax.md | 19 ++++++++++--------- .../create-space-syntax.md | 9 +++------ .../create-tag-edge-syntax.md | 6 +++--- 4 files changed, 18 insertions(+), 23 deletions(-) diff --git a/docs/manual-CN/2.query-language/4.statement-syntax/1.data-definition-statements/create-space-syntax.md b/docs/manual-CN/2.query-language/4.statement-syntax/1.data-definition-statements/create-space-syntax.md index a54a77a1c8f..3d86d2f27de 100644 --- a/docs/manual-CN/2.query-language/4.statement-syntax/1.data-definition-statements/create-space-syntax.md +++ b/docs/manual-CN/2.query-language/4.statement-syntax/1.data-definition-statements/create-space-syntax.md @@ -1,11 +1,8 @@ # CREATE SPACE 语法 ```ngql -CREATE SPACE (IF NOT EXIST) space_name - (space_option,...) - -space_option: - option_name = value +CREATE SPACE [IF NOT EXIST] + [(partition_num = $your_num, replica_factor = $your_num)] ``` 以上语句用于创建一个新的图空间。不同的图空间是物理隔离的。 diff --git a/docs/manual-CN/2.query-language/4.statement-syntax/1.data-definition-statements/create-tag-edge-syntax.md b/docs/manual-CN/2.query-language/4.statement-syntax/1.data-definition-statements/create-tag-edge-syntax.md index 54a9309da69..13510a75ca0 100644 --- a/docs/manual-CN/2.query-language/4.statement-syntax/1.data-definition-statements/create-tag-edge-syntax.md +++ b/docs/manual-CN/2.query-language/4.statement-syntax/1.data-definition-statements/create-tag-edge-syntax.md @@ -1,19 +1,20 @@ # CREATE TAG / EDGE 语法 ```ngql -CREATE {TAG | EDGE} (IF NOT EXIST) tag_name|edge_name - (create_definition, ...) +CREATE | [IF NOT EXIST] | + ([, ...]) [tag_edge_options] -create_definition: - prop_name data_type + ::= + -tag_edge_options: - option [, option ...] + ::= +