Orientdb 简明教程
OrientDB - Update Edge
Update edge 命令用于更新当前数据库中的边记录。这相当于实际的 update 命令,除了在事件中检查和维护与顶点的一致性外,还可以更新 out 和 in 属性。
Update edge command is used to update edge records in the current database. This is equivalent to actual update command in addition to checking and maintaining graph consistency with vertices, in the event that you update the out and in properties.
以下语句是更新边命令的基本语法。
The following statement is the basic syntax of Update Edge Command.
UPDATE EDGE <edge>
[SET|INCREMENT|ADD|REMOVE|PUT <field-name> = <field-value> [,]*]|[CONTENT|MERGE <JSON>]
[RETURN <returning> [<returning-expression>]]
[WHERE <conditions>]
[LOCK default|record]
[LIMIT <max-records>] [TIMEOUT <timeout>]
以下是上文中选项的详细信息。
Following are the details about the options in the above syntax.
<edge> − 定义要更新的边。你可以在 Class 中选择按类型更新边,在以 Cluster 为前缀的 Cluster 中按群集更新边,或在 Record ID 中按记录 ID 更新边。
<edge> − Defines the edge that you want to update. You can choose between Class that updates edges by class, Cluster that updates edges by cluster, using CLUSTER prefix, or Record ID that updating edges by record ID.
SET − 将字段更新为给定值。
SET − Updates the field to the given values.
INCREMENT − 将给定字段加上该值。
INCREMENT − Increments the given field by the value.
ADD − 定义一个项目以添加到字段集合中。
ADD − Defines an item to add to a collection of fields.
REMOVE − 定义一个项目以从字段集合中删除。
REMOVE − Defines an item to remove from a collection of fields.
PUT − 定义入口以放入映射字段中。
PUT − Defines an entry to put into map fields.
RETURN − 定义在运行更新后要返回的表达式。
RETURN − Defines the expression you want to return after running the update.
WHERE − 定义筛选条件。
WHERE − Defines the filter condition.
LOCK − 定义在加载和更新之间记录锁定的方式。
LOCK − Defines how the record locks between the load and updates.
LIMIT − 定义最大记录数。
LIMIT − Defines the maximum number of records.
Example
让我们考虑一个通过从区域 ID = 001 和人员姓名 = Krishna 的地址表获取数据来更新人员类型中的“address”边的示例。
Let us consider an example of updating the edge named ‘address’ in the person class by taking data from the address table having area Id = 001, and the person name = Krishna.
orientdb> UPDATE EDGE address SET out = (SELECT FROM Address WHERE areaID = 001)
WHERE name = 'krishna'
如果成功执行了以上查询,您会获得以下输出。
If the above query is executed successfully, you will get the following output.
Updated edge '[address[#10:3][#11:3->#14:2]]' in 0.012000 sec(s)