Appearance
ROLLBACK
Roll back the current transaction, discarding any changes that the transaction would have committed.
ROLLBACK [ WORK | TRANSACTION ]
For example, the season
table is not dropped because the ROLLBACK command ends the transaction:
premdb=# begin;
BEGIN
premdb=# drop table season;
DROP TABLE
premdb=# rollback;
ROLLBACK
premdb=# \d season
Table "public.season"
Column | Type | Modifiers
-------------+-----------------------+-----------
seasonid | smallint |
season_name | character(9) |
numteams | smallint |
winners | character varying(30) |
Distribution: Replicated
If no transaction is in progress, the ROLLBACK command returns a warning and has no other effect:
premdb=# rollback;
WARNING: there is no transaction in progress
ROLLBACK