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

create space as #1045

Merged
merged 2 commits into from
Oct 13, 2021
Merged
Changes from all 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
26 changes: 24 additions & 2 deletions docs-2.0/3.ngql-guide/9.space-statements/1.create-space.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
# CREATE SPACE

图空间是Nebula Graph中彼此隔离的图数据集合,与MySQL中的database概念类似。`CREATE SPACE`语句可以通过指定名称创建一个新的图空间
图空间是Nebula Graph中彼此隔离的图数据集合,与MySQL中的database概念类似。`CREATE SPACE`语句可以创建一个新的图空间,或者克隆现有图空间的Schema

## 前提条件

只有God角色的用户可以执行`CREATE SPACE`语句。详情请参见[身份验证](../../7.data-security/1.authentication/1.authentication.md)。

## 语法

### 创建图空间

```ngql
CREATE SPACE [IF NOT EXISTS] <graph_space_name> (
[partition_num = <partition_number>,]
Expand Down Expand Up @@ -46,6 +48,17 @@ CREATE SPACE [IF NOT EXISTS] <graph_space_name> (

`graph_space_name`, `partition_num`, `replica_factor`, `vid_type`, `comment` 设置后就无法改变。除非[`DROP SPACE`](./5.drop-space.md),并重新`CREATE SPACE`。

### 克隆图空间

```ngql
CREATE SPACE <new_graph_space_name> AS <old_graph_space_name>;
```

|参数|说明|
|:---|:---|
|`<new_graph_space_name>`|目标图空间名称。该图空间必须未创建。图空间名称由大小写英文字母、数字或下划线组成,区分大写小,且不可使用[关键字和保留字](../../3.ngql-guide/1.nGQL-overview/keywords-and-reserved-words.md)。创建时会克隆`<old_graph_space_name>`图空间的Schema,包括图空间本身参数(分片数量、副本数量等),以及Tag、Edge type和原生索引。|
|`<old_graph_space_name>`|原始图空间名称。该图空间必须已存在。|

## 示例

```ngql
Expand All @@ -57,9 +70,18 @@ nebula> CREATE SPACE my_space_2 (partition_num=15, replica_factor=1, vid_type=FI

# 指定分片数量、副本数量和VID类型,并添加描述。
nebula> CREATE SPACE my_space_3 (partition_num=15, replica_factor=1, vid_type=FIXED_STRING(30)) comment="测试图空间";

# 克隆图空间。
nebula> CREATE SPACE my_space_4 as my_space_3;
nebula> SHOW CREATE SPACE my_space_4;
+--------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Space | Create Space |
+--------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| "my_space_4" | "CREATE SPACE `my_space_4` (partition_num = 15, replica_factor = 1, charset = utf8, collate = utf8_bin, vid_type = FIXED_STRING(30)) ON default comment = '测试图空间'" |
+--------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
```

## 创建图空间说明
## 图空间说明

!!! caution

Expand Down