First, I set John
to the user-defined variable @name
as shown below:
SET @name = 'John';
Then, I set David
to @name
in a transaction, then rollbacked as shown below:
BEGIN;
SET @name = 'David';
ROLLBACK;
But, @name
was not rollbacked to John
as shown below:
mysql> SELECT @name;
+-------+
| @name |
+-------+
| David |
+-------+
I read the doc about transaction and user-defined variables but I could not find any relevant information.
So, how can I rollback user-defined variables?