Commits an open transaction in the current session.
WORK
Optional keyword that provides compatibility with other database systems.
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!
Copy
The rules can be more complex if you are using autonomous scoped transactions and stored procedures.
Begin a transaction, insert some values into a table, then complete the transaction by committing it:
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 | +----------+
Copy
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4