A TRANSACTION is the fundamental mechanism for ensuring data integrity in relational databases. When a transaction begins, the database records all subsequent changes in a temporary state. If the client issues COMMIT, the changes become permanent and visible to other sessions. If ROLLBACK is issued, every change made since the start of the transaction is undone, leaving the database exactly as it was. Transactions guarantee the ACID properties: Atomicity, Consistency, Isolation, Durability. Most databases run in autocommit mode by default, meaning each statement is its own transaction unless explicitly wrapped in BEGIN or START TRANSACTION. Long-running or poorly isolated transactions can cause locks, deadlocks, and performance bottlenecks. Some systems support nested transactions through SAVEPOINTs, while others do not. Each session manages its own transaction boundaries; there is no global transaction across sessions unless using distributed transaction managers.
COMMIT, ROLLBACK, SAVEPOINT, BEGIN, ISOLATION LEVEL, AUTOCOMMIT
SQL-92 standard
Both start a new transaction. BEGIN is supported by more systems, while START TRANSACTION is explicit in MySQL and PostgreSQL. In most cases they are interchangeable.
The transaction stays open, locking affected rows or tables. When the session ends, many databases automatically roll back, but resources remain locked until then.
It depends on the database. PostgreSQL and recent MySQL versions treat most DDL as transactional. SQL Server auto-commits DDL. Always check your engine.
Many drivers expose functions like txid_current() in PostgreSQL or @@TRANCOUNT in SQL Server. You can also query session status views specific to your database.