This Oracle tutorial explains how to use the Oracle COMMIT statement with syntax and examples.
In Oracle, the COMMIT statement commits all changes for the current transaction. Once a commit is issued, other users will be able to see your changes.
The syntax for the COMMIT statement in Oracle/PLSQL is:
Optional. It was added by Oracle to be SQL-compliant. Issuing the COMMIT with or without the WORK parameter will result in the same outcome.
Optional. It is used to specify a comment to be associated with the current transaction. The comment that can be up to 255 bytes of text enclosed in single quotes. It is stored in the system view called DBA_2PC_PENDING along with the transaction ID if there is a problem.
Optional. It is used to specify the priority that the redo information for the committed transaction is to be written to the redo log. With this clause, you have two parameters to specify:
Optional. It is used to force the commit of a transaction that may be corrupt or in doubt. With this clause, you can specify the FORCE in 3 ways:
Let's look at an example that shows how to issue a commit in Oracle using the COMMIT statement.
For example:
This COMMIT example would perform the same as the following:
In this example, the WORK keyword is implied and the omission of the WRITE clause would default to WRITE WAIT IMMEDIATE so the first 2 COMMIT statements are equivalent.
Let's look at an example of a COMMIT that shows how to use the COMMENT clause:
For example, you can write the COMMIT with a comment in two ways:
OR
Since the WORK keyword is always implied, both of these COMMIT examples are equivalent. The COMMIT would store the comment enclosed in quotes along with the transaction ID in the DBA_2PC_PENDING system view, if the transaction was in error or in doubt.
Finally, look at an example of a COMMIT that shows how to use the FORCE clause.
For example, you can write the COMMIT of an in-doubt transaction in two ways:
OR
Since the WORK keyword is always implied, both of these COMMIT examples would force the commit of the corrupted or in doubt transaction identified by the transaction ID '22.14.67'.