Reputation: 125
Suppose I defined two variables in mysql as follows:
SET @STUDENT_NAME = 'ABCD';
SET @STUDENT_AGE = 25;
Now, When I'm was selecting these two variables value using following:
SELECT @STUDENT_NAME, @STUDENT_AGE;
It was perfectly showing corresponding values, even if I switched the database.
But when I restarted mysql and tried to select these values, It was showing null values of these variables, So where would it be stored actually when I had set values?
Upvotes: 0
Views: 82
Reputation: 8395
Per the manual (emphasis mine):
https://dev.mysql.com/doc/refman/8.0/en/user-variables.html
User-defined variables are session specific. A user variable defined by one client cannot be seen or used by other clients. (Exception: A user with access to the Performance Schema user_variables_by_thread table can see all user variables for all sessions.) All variables for a given client session are automatically freed when that client exits.
Upvotes: 1