Home > Database > Mysql Tutorial > body text

System variables and local variables in MySQL?

王林
Release: 2023-09-15 16:21:02
forward
693 people have browsed it

MySQL 中的系统变量与局部变量?

The scope of local variables is limited to a set of statements or statement blocks. Whenever a set of statements or block of statements completes, local variables go out of scope.

For example

Local variables can be used in stored procedures, functions, etc. Used together with the DECLARE keyword.

The syntax of local variables is as follows.

DECLARE yourVariableName dataType;
Copy after login

Global or system variables have cross-connection scope until the server is restarted. It is set using the GLOBAL keyword. The syntax is as follows -

SET GLOBAL max_connections=value;
OR
SET @@global.max_connections=value;
Copy after login

If you know the port number, you can use the system variable @@port using the select statement. The query is as follows -

mysql> select @@port;
Copy after login

Output

The following is the output -

+--------+
| @@port |
+--------+
| 3306 |
+--------+
1 row in set (0.00 sec)
Copy after login

The above is the detailed content of System variables and local variables in MySQL?. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!