Question: What are User-Defined Variables in MySQL?
User-Defined variables are variable that defined by user as per there need. Once they exit from the console, will be removed automatically.
Question: How to set User-Defined Variables in MySQL?
set @name="this is new variable";
Question: How to get User-Defined Variables in MySQL?
select @name;
Question: Can we define multiple variable in single line?
Yes, We can.
set @num1=10, @num2=20, @num3=30;
Question: Can we do arithmetic operators on variable?
Yes, we can do.
select @num1+@num2+@num3; //60 select @num1+@num2+@num3; //6000
Question: Is user defined variable are permanent?
No, It will be removed once close the session.
Question: Can we use user variable with Query?
Yes, If you have defined in same session, then you can use.
Question: What are System Variables?
System Variables explains how your MySQL server are configured and you can change as per your requirement.
Question: How to get the value from system variable?
select @@max_connections; //100
Question: How to update the value from system variable globally?
set @@global.max_connections=200;
set GLOBAL @@max_connections=200;