Orientdb 简明教程
OrientDB - Commit Database
与 RDBMS 相似,OrientDB 也提供了提交和回滚等事务概念。 Commit 指关闭事务,通过将所有更改保存到数据库。 Rollback 指恢复数据库状态到打开事务时的那个点。
Similar to RDBMS, OrientDB also provides transaction concepts like Commit and Rollback. Commit refers to closing the transaction by saving all changes to the database. Rollback refers to recovering the database state to the point where you opened the transaction.
以下命令为提交数据库命令的基本语法。
The following statement is the basic syntax of the Commit database command.
COMMIT
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 commit 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')
您可以使用以下命令执行事务。
You can use the following command to commit the transaction.
orientdb> commit
如果成功提交这个事务,你会看到以下的输出。
If this transaction is successfully committed, you will get the following output.
Transaction 2 has been committed in 4ms