命令 - ROLLBACK

中止一个事务,将数据库回滚到它的保存点。

语法

BEGIN

更多事务的信息,参考Transactions。初始化一个事务,使用命令BEGIN。保存变更,使用命令COMMIT

例子

  • 初始化一个新事务:

    orientdb> BEGIN
    
    Transaction 1 is running
    
  • 尝试启动一个新事事务:

    orientdb> BEGIN
    
    Error: an active transaction is currently open (id=1). Commit or rollback before starting a new one.
    
  • 执行一些变更:

    orientdb> INSERT INTO Account (name) VALUES ('tx test')
    
    Inserted record 'Account#9:-2{name:tx test} v0' in 0,004000 sec(s).
    
  • 查看数据库的变更:

    orientdb> SELECT FROM Account WHERE name LIKE 'tx%'
    
    ---+-------+--------------------
     # | RID   | name
    ---+-------+--------------------
     0 | #9:-2 | tx test
    ---+-------+--------------------
    1 item(s) found. Query executed in 0.076 sec(s).
    
  • 中止事务:

    orientdb> ROLLBACK
    
    Transaction 1 has been rollbacked in 4ms
    
  • 查看回滚后的数据库:

    orientdb> SELECT FROM Account WHERE name LIKE 'tx%'
    
    0 item(s) found. Query executed in 0.037 sec(s).