Console - BEGIN
Initiates a transaction. When a transaction is open, any commands you execute on the database remain temporary. In the event that you are satisfied with the changes, you can call the COMMIT
command to commit them to the database. Otherwise, you can call the ROLLBACK
command, to roll the changes back to the point where you called BEGIN
.
Syntax:
BEGIN
Examples
Begin a transaction:
- orientdb>
BEGIN
- Transaction 1 is running
- orientdb>
Attempting to begin a transaction when one is already open:
- orinetdb>
BEGIN
- Error: an active transaction is currently open (id=1). Commit or rollback
- before starting a new one.
- orinetdb>
Making changes when a transaction is open:
- orientdb>
INSERT INTO Account (name) VALUES ('tx test')
SELECT FROM Account WHERE name LIKE 'tx%'
- ---+-------+----------
- # | RID | name
- ---+-------+----------
- 0 | #9:-2 | tx test
- ---+-------+----------
- orientdb>
When a transaction is open, new records all have temporary Record ID’s, which are given negative values, (for instance, like the #9:-2
shown above). These remain in effect until you run COMMIT
For more information on Transactions, see