Orientdb 简明教程
OrientDB - Rollback Database
在本章中,你将学会如何通过 OrientDB 命令行界面,回滚尚未提交的事务。
In this chapter, you will learn how to roll back the un-committed transaction through the OrientDB command line interface.
以下命令为回滚数据库命令的基本语法。
The following statement is the basic syntax of the Rollback database command.
ROLLBACK
Note −您必须在连接到特定的数据库并且开始事务之后才能使用此命令。
Note − You can use this command only after connecting to a particular database and after beginning the transaction.
Example
在这个例子中,我们会使用上一章建立的,叫做“demo”的相同数据库。我们将会看到回滚事务的操作,以及通过事务储存记录。
In this example, we will use the same database named ‘demo’ that we created in the previous chapter. We will see the operation of rollback transaction and store a record using transactions.
首先,使用以下 BEGIN 命令开始事务。
First, start the transaction using the following BEGIN command.
orientdb {db = demo}> BEGIN
然后,使用以下命令,插入一条 id = 12 且 name = satish.P 的记录到 employee 表中。
Then, insert a record into an employee table with the values id = 12 and name = satish.P using the following command.
orientdb> INSERT INTO employee (id, name) VALUES (12, 'satish.P')
你可以使用以下命令,从 Employee 表中检索记录。
You can use the following command to retrieve the records from the Employee table.
orientdb> SELECT FROM employee WHERE name LIKE '%.P'
如果成功执行此命令,您将得到以下输出。
If this command is executed successfully, you will get the following output.
---+-------+--------------------
# | ID | name
---+-------+--------------------
0 | 12 | satish.P
---+-------+--------------------
1 item(s) found. Query executed in 0.076 sec(s).
你现在可以使用以下命令,来回滚这个事务。
You can now use the following command to Rollback this transaction.
orientdb> ROLLBACK
再次检查 select 查询,来从 employee 表中检索相同的记录。
Check the select query again to retrieve the same record from the employee table.
orientdb> SELECT FROM employee WHERE name LIKE '%.P'
如果回滚成功执行,你会在输出中看到 0 条已找到的记录。
If the rollback is executed successfully, you will get 0 records found in the output.
0 item(s) found. Query executed in 0.037 sec(s).