Orientdb 简明教程

OrientDB - Move Vertex

OrientDB 中的移动顶点命令是将一个或多个顶点从当前位置移动到不同的类或集群。如果你将移动命令应用于特定顶点,则它将更新连接到此顶点的所有边。如果你指定一个集群来移动顶点,则它会将顶点移动到目标集群的所有者服务器。

Move Vertex command in OrientDB is to move one or more vertices from current location to different class or cluster. If you are applying move command on a particular vertex, then it will update all the edges that are connected to this vertex. If you are specifying a cluster to move vertex, then it moves the vertices to the server owner of the target cluster.

以下语句是 Move Vertex 命令的基本语法。

The following statement is the basic syntax of Move Vertex Command.

MOVE VERTEX <source> TO <destination>
[SET [<field>=<value>]* [,]]
[MERGE <JSON>]
[BATCH <batch-size>]

以下是上文中选项的详细信息。

Following are the details about the options in the above syntax.

<source> - 定义要移动的顶点。它接受特定顶点的记录 ID 或顶点的记录 ID 数组。

<source> − Defines the vertex you want to move. It accepts Record ID of a particular vertex or array of Record IDs for vertices.

<destination> - 定义要将顶点移动到哪里。它将类或集群作为目的地。

<destination> − Defines where you want to move the vertex. It supports either class or a cluster as destination.

SET - 向字段设置值。

SET − Sets the values to fields.

MERGE − 通过 JSON 设置字段的值。

MERGE − Sets the values to fields through JSON.

BATCH − 定义批处理大小。

BATCH − Defines the batch size.

Note − 此命令更新所有已连接的边,但不更新链接。在使用图 API 时,建议使用连到顶点的边。

Note − This command updates all connected edges, but not links. When using Graph API, it is recommended to use edge connected to vertices.

Example

尝试以下示例来了解如何移动顶点。

Try the following examples to learn how to move vertices.

执行以下查询,将记录 ID 为 #11:2 的单个顶点从当前位置移到员工类别。

Execute the following query to move a single vertex having Record ID #11:2 from its current position to Class Employee.

orientdb> MOVE VERTEX #11:2 TO CLASS:Employee

如果以上查询执行成功,您将获得以下输出 −

If the above query is executed successfully, you will get the following output −

Move vertex command executed with result '[{old:#11:2, new:#13:0}]' in 0.022000 sec(s)

执行以下查询,将一组顶点从“客户”类别移到“员工”类别。

Execute the following query to move set of vertices from the class ‘Customer’ to class ‘Employee’.

orientdb> MOVE VERTEX (SELECT FROM Customer) TO CLASS:Employee

如果成功执行了以上查询,您会获得以下输出。

If the above query is executed successfully, you will get the following output.

Move vertex command executed with result '[{old:#11:0,
new:#13:1},{old:#11:1, new:#13:2},{old:#11:2, new:#13:3}]' in 0.011000 sec(s)