
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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
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.
For Example
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;
Output
The following is the output −
+--------+ | @@port | +--------+ | 3306 | +--------+ 1 row in set (0.00 sec)
Advertisements