Transaction Control Statements |
Transaction control statements manage the changes made by DML statements and group DML statements into transactions. They enable you to:
Undo the changes in a transaction, either since the transaction started or since a savepoint (ROLLBACK)
This topic includes the following topics:
The SQL COMMIT statement saves any changes you have made to the database. When a COMMIT has been executed, all the recent changes since the last COMMIT, or since you logged on as the current user, are saved.
Example: Using the COMMIT Statement shows how to use COMMIT to commit (save) changes to the employees table in the database.
Using the COMMIT Statement
-- add a row and then update the data INSERT INTO employees (employee_id, last_name, email, hire_date, job_id, salary) VALUES (301, 'Doe', 'john.doe', '31-AUG-05', 'SH_CLERK', 2400); UPDATE employees SET salary = salary*1.10 WHERE employee_id = 301; -- commit (save) the INSERT and UPDATE changes in the database COMMIT;
|
See Also:
|
You can use the SQL ROLLBACK statement to rollback (undo) any changes you made to the database before a COMMIT has been executed.
Example: Using the ROLLBACK Statement shows how to use ROLLBACK to rollback the deletions made to the employees table. Note that the ROLLBACK was issued before a COMMIT was executed.
Using the ROLLBACK Statement
-- delete a row (record) DELETE FROM employees WHERE last_name = 'Doe'; -- rollback the delete statement because the previous DELETE was incorrect ROLLBACK; -- the following is valid SELECT * FROM employees WHERE last_name = 'Doe';
|
See Also:
|