Orientdb 简明教程
OrientDB - Delete Record
Delete Record 命令用于从数据库中完全删除一个或多个记录。
Delete Record command is used to delete one or more records completely from the database.
以下语句是删除命令的基本语法。
The following statement is the basic syntax of the Delete command.
DELETE FROM <Class>|cluster:<cluster>|index:<index>
[LOCK <default|record>]
[RETURN <returning>]
[WHERE <Condition>*]
[LIMIT <MaxRecords>]
[TIMEOUT <timeout>]
以下是上文中选项的详细信息。
Following are the details about the options in the above syntax.
LOCK - 指定如何在加载和更新之间锁定记录。我们有两个选项来指定 Default 和 Record 。
LOCK − Specifies how to lock the records between load and update. We have two options to specify Default and Record.
RETURN − 指定要在记录数量中返回的表达式。
RETURN − Specifies an expression to return instead of the number of records.
LIMIT − 定义要更新的最大记录数量。
LIMIT − Defines the maximum number of records to update.
TIMEOUT − 定义在超时前允许更新运行的时间。
TIMEOUT − Defines the time you want to allow the update run before it times out.
Note − 不要使用 DELETE 删除点或边,因为它会影响图表的完整性。
Note − Don’t use DELETE to remove Vertices or Edges because it effects the integrity of the graph.
Example
我们以客户表为例。
Let us consider the Customer table.
Sr.No. |
Name |
Age |
1 |
Satish |
25 |
2 |
Krishna |
26 |
3 |
Kiran |
29 |
4 |
Javeed |
21 |
尝试使用以下查询来删除 id = 4 的记录。
Try the following query to delete the record having id = 4.
orientdb {db = demo}> DELETE FROM Customer WHERE id = 4
如果成功执行了以上查询,您会获得以下输出。
If the above query is executed successfully, you will get the following output.
Delete 1 record(s) in 0.008000 sec(s).
要检查客户表中的记录,可以使用以下查询。
To check the record of Customer table you can use the following query.
Orientdb {db = demo}> SELECT FROM Customer
如果成功执行了以上查询,您会获得以下输出。
If the above query is executed successfully, you will get the following output.
----+-----+--------+----+-------+----
# |@RID |@CLASS |id |name |age
----+-----+--------+----+-------+----
0 |#11:0|Customer|1 |satish |25
1 |#11:1|Customer|2 |krishna|26
2 |#11:2|Customer|3 |kiran |29
----+-----+--------+----+-------+----