Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[doc]add if not exists #1407

Merged
merged 6 commits into from
Dec 18, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
# CREATE SPACE 语法

```ngql
CREATE SPACE space_name
(space_option,...)

space_option:
option_name = value
CREATE SPACE [IF NOT EXIST] <space_name>
[(partition_num = $your_num, replica_factor = $your_num)]
```

以上语句用于创建一个新的图空间。不同的图空间是物理隔离的。

## IF NOT EXIST

创建图空间新增 `IF NOT EXIST` 关键字,这个关键字会自动检测对应的图空间是否存在,如果不存在则创建新的,如果存在则直接返回。
amber-moe marked this conversation as resolved.
Show resolved Hide resolved

**注意:** 这里判断图空间是否存在只是比较图空间的名字(不包括属性)。

## Space Name 图空间名

* **space_name**

图空间的名称在集群中标明了一个唯一的空间。命名规则详见 [Schema Object Names](../../3.language-structure/schema-object-names.md)

### Space Options 图空间选项
## Space Options 图空间选项
amber-moe marked this conversation as resolved.
Show resolved Hide resolved

在创建图空间的时候,可以传入自定义选项。选项名称 _option_name_ 可以是以下任何一个:

Expand All @@ -30,7 +33,7 @@ space_option:

如果没有自定义选项,**Nebula Graph** 会使用默认的值(partition_number 和 replica_factor)来创建图空间。

### 示例
## 示例

```ngql
nebula> CREATE SPACE my_space_1; -- 使用默认选项创建图空间
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,32 @@
# CREATE TAG / EDGE 语法

```ngql
CREATE {TAG | EDGE} tag_name|edge_name
(create_definition, ...)
CREATE TAG | EDGE [IF NOT EXIST] <tag_name> | <edge_name>
amber-moe marked this conversation as resolved.
Show resolved Hide resolved
([<create_definition>, ...])
[tag_edge_options]

create_definition:
prop_name data_type
<create_definition> ::=
<prop_name> <data_type>

tag_edge_options:
option [, option ...]
<tag_edge_options> ::=
<option> [, <option> ...]

option:
TTL_DURATION [=] ttl_duration
| TTL_COL [=] prop_name
<option> ::=
TTL_DURATION [=] <ttl_duration>
| TTL_COL [=] <prop_name>
| DEFAULT <default_value>
```

**Nebula Graph** 的图结构由带有属性的 tags 和 edges 组成。`CREATE TAG` 使用一个给定的名称创建一个新的 tag。`CREATE EDGE` 则创建一个新的 edge type。

`CREATE TAG/EDGE` 语法有一些特点,在如下分块中将对这些特点进行讨论:

## IF NOT EXIST

创建 tag 或 edge 新增 `IF NOT EXIST` 关键字,这个关键字会自动检测对应的 tag 或 edge 是否存在,如果不存在则创建新的,如果存在则直接返回。
amber-moe marked this conversation as resolved.
Show resolved Hide resolved

**注意:** 这里判断 tag 或 edge 是否存在只是比较 tag 或 edge 的名字(不包括属性)。

## Tag 名称和 Edge Type 名称

* **tag_name 和 edge_name**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
# Create Space Syntax

```ngql
CREATE SPACE space_name
(space_option,...)

space_option:
option_name = value
CREATE SPACE [IF NOT EXIST] <space_name>
[(partition_num = $your_num, replica_factor = $your_num)]
```

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 the `If NOT EXIST` keywords 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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keyword not keywords

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't agree. 3 words here.


**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:

Expand All @@ -30,7 +33,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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Create TAG / EDGE Syntax

```ngql
CREATE {TAG | EDGE} <tag_name> | <edge_name>
(<create_definition>, ...)
CREATE TAG | EDGE [IF NOT EXIST] <tag_name> | <edge_name>
([<create_definition>, ...])
[tag_edge_options]

<create_definition> ::=
Expand All @@ -21,6 +21,12 @@ CREATE {TAG | EDGE} <tag_name> | <edge_name>

The features of this syntax are described in the following sections:

## IF NOT EXIST

We added the `If NOT EXIST` keywords 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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keyword


**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**
Expand Down