Closes a transaction, committing the changes you have made to the database. Use the BEGIN
command to open a transaction. If you don't want to save the changes you've made, use the ROLLBACK
command to revert the database state back to the point where you opened the transaction.
For more information, see Transactions.
Syntax
COMMIT
Example
-
Initiate a transaction, using the
BEGIN
command:orientdb>
BEGIN
Transaction 2 is running -
For the sake of example, attempt to open another transaction:
orientdb>
BEGIN
Error: an active transaction is currently open (id=2). Commit or rollback before starting a new one. -
Insert data into the class
Account
, using anINSERT
statement:orientdb>
INSERT INTO Account (name) VALUES ('tx test')
Inserted record 'Account#9:-2{name:tx test} v0' in 0,000000 sec(s). -
Commit the transaction to the database:
orientdb>
COMMIT
Transaction 2 has been committed in 4ms -
Display the new content, using a
SELECT
query:orientdb>
SELECT FROM Account WHERE name LIKE 'tx%'
---+---------+---------- # | RID | name ---+---------+---------- 0 | #9:1107 | tx test ---+---------+---------- 1 item(s) found. Query executed in 0.041 sec(s).
When a transaction is open, all new records use a temporary Record ID that features negative numbers. After the commit, they have a permanent Record ID that uses with positive numbers.
For more information, see