PostgreSQL Commit
Transaction Control:
There are following commands used to control transactions:
The BEGIN TRANSACTION Command:
Transactions can be started using BEGIN TRANSACTION or simply BEGIN command. Such transactions usually persist until the next COMMIT or ROLLBACK command is encountered. But a transaction will also ROLLBACK if the database is closed or if an error occurs.
Following is the simple syntax to start a transaction:
There are following commands used to control transactions:
- BEGIN TRANSACTION: to start a transaction.
- COMMIT: to save the changes, alternatively you can use END TRANSACTION command.
- ROLLBACK: to rollback the changes.
The BEGIN TRANSACTION Command:
Transactions can be started using BEGIN TRANSACTION or simply BEGIN command. Such transactions usually persist until the next COMMIT or ROLLBACK command is encountered. But a transaction will also ROLLBACK if the database is closed or if an error occurs.
Following is the simple syntax to start a transaction:
BEGIN;
or
BEGIN TRANSACTION;
The COMMIT Command:- The COMMIT command is the transactional command used to save changes invoked by a transaction to the database.
- The COMMIT command saves all transactions to the database since the last COMMIT or ROLLBACK command.
COMMIT;
or
END TRANSACTION;
Comments
Post a Comment