MySQL savepoint transaction

Start the transaction first
START TRANSACTION;
INSERT into city VALUES(NULL,”pankaj”,”7");
After the insertion is successful, we set a save point here a
SAVEPOINT a;
INSERT into city VALUES(NULL,”pankajtest”,”8");
After the insertion is successful, we set a save point here b
SAVEPOINT b;
INSERT into city VALUES(“pankaj”,”9");
There is an error in the sql statement here
INSERT into city VALUES(“pankajdoc”,”9")
> 1136 — Column count doesn’t match value count at row 1
5. Here we use the save point to roll back
rollback to SAVEPOINT a;
Roll back to a successful
rollback to SAVEPOINT a
> OK

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Pankaj kushwaha

Pankaj kushwaha

Database/System Administrator | DevOPS | Cloud Specialist | DevOPS