Abort

Rolls back changes made during a transaction block.

Synopsis

ABORT [ WORK | TRANSACTION ]

Parameters

WORK | TRANSACTION

A pair of optional noise keywords. They can be ignored, or used to make your SQL more readable.

Results

ROLLBACK

The message returned when an ABORT completes successfully.

NOTICE: ROLLBACK: no transaction in progress

The notice returned if the database server is unable to find any transaction in progress.

Examples

The following example demonstrates the use of ABORT to undo an accidental DELETE command:

booktown=# BEGIN WORK;
BEGIN
booktown=# DELETE FROM publishers WHERE id < 100;
DELETE 6
booktown=# ABORT WORK;
ROLLBACK

Get Practical PostgreSQL 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.