This article was reproduced from: http://www.cnblogs.com/linjiqin/archive/2011/04/18/2019990.html
1. Transactions are used to ensure consistency of data, consisting of a set of related DML statements that are either fully or completely canceled by the actions performed by that group of DML statements.
2. When performing transaction operations (DML), Oracle locks on the table being made to prevent other users from altering the table structure, and also adds a row lock on the rows being manipulated to prevent other transactions from performing DML operations on the corresponding rows.
3. When a transaction commit or transaction rollback is performed, Oracle confirms the transaction changes or rolls back the transaction, ends the transaction, deletes the savepoint, and releases the lock.
4. Commit TRANSACTION (COMMIT) Confirm transaction change, end current transaction, delete savepoint, release lock, make all pending data in current transaction permanent change.
5. Save Point (SavePoint) in the current transaction, mark the savepoint of the transaction.
6. Rollback TRANSACTION (ROLLBACK) rolls back the entire transaction, deletes all the save points defined by the firm, releases the lock, discards any pending data changes.
7. Rolls back the transaction to the specified SavePoint (ROLLBACK to SavePoint), rolls back the current transaction to the specified savepoint, discards any changes made after the savepoint is created, and releases the lock.
8. When executing DDL, DCL statements, or exiting Sql*plus, the transaction is automatically committed;
9. Avoid interaction with users during the business period;
10, the query data period, try not to start the transaction;
11, as far as possible to keep the shorter the better the transaction;
12. The minimum amount of data to be accessed as much as possible in the transaction
Create or Replace procedureStu_proc (v_idinch Number, V_nameinch varchar2, V_ageinch Number, v_msg outvarchar2) asbegin Insert intoStudent (ID, sname, age)Values(v_id, V_name, v_age); Commit; V_msg:='Add Success'; exception whenOthers Then rollback; V_msg:='failed successfully'; Raise_application_error (-20010,'ERROR: Violating the unique index constraint! ');End;
Go Transactions in Oracle Stored procedures