Is it possible to rollback only one command (not whole transaction) in SQL?

919 Views Asked by At

I know that you do the BEGIN; command, then all commands after that can be rolled back, as long as you haven't executed COMMIT; yet. My question is, is there a command to roll back just one command and not ALL commands after the BEGIN? I'm using Postgres by the way.

1

There are 1 best solutions below

4
On

Read https://www.postgresql.org/docs/14/tutorial-transactions.html about SAVEPOINT and ROLLBACK TO SAVEPOINT.