A (Very) Short Introduction to Transaction Processing

You might have noticed two new commands in this example. The BEGIN WORK and ROLLBACK commands are used for transaction processing. A transaction is a group of commands. Usually, a transaction includes one or more table modifications (INSERTs, DELETEs, and UPDATEs).

BEGIN WORK marks the beginning of a transaction. Inside of a transaction, any changes that you make to the database are temporary changes. There are two ways to mark the end of a transaction: COMMIT and ROLLBACK. If you COMMIT a transaction, you are telling PostgreSQL to write all the changes made within the transaction into the database—in other words, when you COMMIT a transaction, the changes become permanent. When you ROLLBACK ...

Get PostgreSQL, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.