mjb
mjb

Reputation: 7979

Is it necessary to run "ROLLBACK" in MYSQL?

I executed multiple queries SQL statement in between START TRANSACTION and COMMIT.

If anything goes wrong, the process terminated in between without executing COMMIT and nothing will happen to the database. So far, everything seems fine without executing ROLLBACK.

My doubt is, is it necessary to run ROLLBACK if anything bad happens?

Upvotes: 4

Views: 1254

Answers (1)

Jcl
Jcl

Reputation: 28272

If you have autocommit disabled, any non-commited transaction is always rolled back at the end of the session.

You can read more about it on the documentation

That said, I'd be explicit about it (just in case the session doesn't end when "something goes wrong") and call it.

Upvotes: 2

Related Questions