- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
System variables vs Local Variables in MySQL?
152 Lectures 16 hours
87 Lectures 5.5 hours
The local variable has the scope for only a set of statements or block of statement. Whenever a set of statements or block of statement has completed then local variable goes out of scope.
Local variable can be used in stored procedure, function etc. It is used with the DECLARE keyword.
The syntax is as follows to local variables.
DECLARE yourVariableName dataType;
The global variables or system variables has the scope across connections until server restart. It is set using GLOBAL keyword. The syntax is as follows −
SET GLOBAL max_connections=value; OR SET @@global.max_connections=value;
If you know port number then you can use system variable @@port using select statement. The query is as follows −
mysql> select @@port;
The following is the output −
+--------+ | @@port | +--------+ | 3306 | +--------+ 1 row in set (0.00 sec)
- User-defined variables vs Local Variables in MySQL?
- System variables vs User-defined variables in MySQL?
- Member variables vs Local variables in Java
- Global vs Local variables in Python
- Local variables in Java
- What are class variables, instance variables and local variables in Java?
- What are local variables and global variables in C++?
- Final local variables in C#
- Global and Local Variables in C#
- What are local variables in C++?
- Global and Local Variables in Python?
- Global and Local Variables in Java
- How can local variables be used in MySQL stored procedure?
- Are static local variables allowed in Java?
- What are Local Scope Variables in Postman?