- Catégories :
COMMIT¶
Effectue un commit d’une transaction ouverte dans la session en cours.
- Voir aussi :
Syntaxe¶
COMMIT
Notes sur l’utilisation¶
If two
COMMIT
statements in a row are executed (within the same scope), the second one is ignored. For example, in the following code, the second COMMIT has no effect; there is no open transaction to commit.begin; insert into table1 ...; commit; commit; -- Ignored!
Les règles peuvent être plus complexes si vous utilisez des transactions autonomes scopées et des procédures stockées .
Exemples¶
Commencer une transaction, insérer des valeurs dans une table, puis terminer la transaction en effectuant un commit :
SELECT COUNT(*) FROM A1; ----------+ COUNT(*) | ----------+ 0 | ----------+ BEGIN NAME T3; SELECT CURRENT_TRANSACTION(); -----------------------+ CURRENT_TRANSACTION() | -----------------------+ 1432071497832 | -----------------------+ INSERT INTO A1 VALUES (1), (2); -------------------------+ number of rows inserted | -------------------------+ 2 | -------------------------+ COMMIT; SELECT CURRENT_TRANSACTION(); -----------------------+ CURRENT_TRANSACTION() | -----------------------+ [NULL] | -----------------------+ SELECT LAST_TRANSACTION(); --------------------+ LAST_TRANSACTION() | --------------------+ 1432071497832 | --------------------+ SELECT COUNT(*) FROM A1; ----------+ COUNT(*) | ----------+ 2 | ----------+