In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article focuses on "the concept of variables in MYSQL". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn the concept of variables in MYSQL.
Variables are divided into user variables and system variables.
User variable:
User variables are related to the connection, and the variables declared in this connection will disappear when the connection is disconnected.
Variables declared in this connection cannot be used in another connection.
The variable name of the user variable is in the form @ varname.
The name must start with @.
You need to use a set statement when declaring a variable, such as the following statement declaring a variable named @ a.
Set @ a = 1
Declare a variable named @ an and assign it to 1, where the data type is not strictly restricted, and its data type varies from time to time according to the value you assign to it.
(the declare statement is used in SQL SERVER to declare variables, and the data type is strictly restricted. )
We can also use the select statement to assign values to variables.
For example:
Set @ name =
Select @ name:=password from user limit 0Pol 1
(note that the equals sign is preceded by a colon, followed by limit 0 top 1, which is used to restrict the returned results, which is equivalent to top 1 in SQL SERVER.)
If you write directly:
Select @ name:=password from user
If the query returns more than one value, the value of the @ name variable is the value of the password field of the last record.
System variable:
System variables are divided into global variables and session variables.
Global variables are automatically initialized to default values by the server when MYSQL starts, which can be changed by changing the file my.ini.
Session variables are initialized by MYSQL each time a new connection is established. MYSQL makes a copy of the values of all current global variables. As a session variable.
(that is, if the values of session variables and global variables have not been changed manually after the session is established, the values of all these variables are the same. )
The difference between global variables and session variables is that changes to global variables affect the entire server, but changes to session variables only affect the current session.
That is, the current database connection.
We can use it.
Show session variables
Statement to output all session variables:
(it can be abbreviated to show variables. If you do not specify whether to output global variables or session variables, the session variables will be output by default. )
Mysql > show global variables
+-+
| | Variable_name | Value |
+-+
| | auto_increment_increment | 1 | |
| | auto_increment_offset | 1 | |
| | automatic_sp_privileges | ON |
.. Omit; omit.
| | tmpdir | C:WINDOWSTEMP |
| | transaction_alloc_block_size | 8192 | |
| | transaction_prealloc_size | 4096 | |
| | tx_isolation | REPEATABLE-READ |
| | updatable_views_with_limit | YES |
| | version | 5.0.67-community-nt |
| | version_comment | MySQL Community Edition (GPL) |
| | version_compile_machine | ia32 & n |
At this point, I believe you have a deeper understanding of "the concept of variables in MYSQL". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.