当前位置:网站首页>MySQL - definition and assignment of variables
MySQL - definition and assignment of variables
2022-06-25 07:13:00 【Python's path to becoming a God】
List of articles
mysql Definition and assignment of variables
have access to declare Keyword to define variables , After definition, you can assign values to variables .
Defining variables
declare my_sql int declare 10;
Assign values to variables
set my_sql =30;
select …into Statement to assign a value to a variable
select id into my_sql from tb_student where id=2;
Variable classification
local variable :
mysql local variable , Can only be used in begin/end In the block .
User variables :
mysql User variables in do not need to be declared in advance , Use... Directly when using “@ Variable name ” Just use it .
Such as :@test=1;
Session variables :
mysql Session variables , The server maintains a series of session variables for each connected client , Its scope is limited to the current connection , That is, the session variables in each connection are independent .
- Show session variables :
show session variables
- Query session variables :
select @@auto_increment_increment;
select@@session.auto_increment_increment;
show session variables like '%auto_increment_increment%'; -- session Keywords can be omitted
- Set session variables :
set session auto_increment_increment=1;
set @@session.auto_increment_increment=2;
set auto_increment_increment=3; -- When omitting session When a keyword , The default is session, That is, set the value of the session variable
-- keyword session You can also use keywords local Instead of
set @@local.auto_increment_increment=1;
select @@local.auto_increment_increment;
Global variables :
Global variables affect the overall operation of the server , When the service starts , It initializes all global variables to default values . To change global variables , Must possess super jurisdiction .
- Show global variables :
show global variables;
- Set global variables :
set global sql_warnings=ON; -- global Don't omit
set@@global.sql_warnings=OFF;
- Query global variables :
-- There are two ways to query the value of a global variable
select @@global.sql_warnings;
show global variables like '%sql_warnings%';
边栏推荐
- Following the last minor upgrade of nodemcu (esp8266)
- 活动报名|Apache Pulsar x KubeSphere 在线 Meetup 火热来袭
- 太美的承诺因为太年轻
- lotus v1.16.0-rc2 Calibration-net
- Tp6 interface returns three elements
- 单片机IO详解(上拉 下拉 准双向 输入 输出 推挽 开漏)
- Your local changes to the following files would be overwritten by merge: . vs/slnx. sqlite
- Qcom--lk phase I2C interface configuration scheme -i2c6
- [C language] add separator to string
- Keil debug view variable prompt not in scope
猜你喜欢
单片机IO详解(上拉 下拉 准双向 输入 输出 推挽 开漏)
レ / leilei
基于 KubeSphere 的分级管理实践
[ros2] Why use ros2? Introduction to ros2 system characteristics
[he doesn't mention love, but every word is love]
Pratique de gestion hiérarchique basée sur kubesphere
Capable people never complain about the environment!
Why use NoSQL with MySQL?
Modify the default log level
Kubernetes core components etcd details
随机推荐
How do I get red green blue (RGB) and alpha back from a UIColor object?
Capable people never complain about the environment!
Derivation of sin (a+b) =sina*cosb+sinb*cosa
Make fertilizer Safi from crop residues locally to increase yield by 30% and improve soil
Ctfhub web information disclosure directory traversal
Editing the date formatting of x-axis tick labels in Matplotlib - editing the date formatting of x-axis tick labels in Matplotlib
使用OpenGL绘制shp文件
Finally, when you open source the applet ~
[Shangshui Shuo series] day 5
Unity get resource path
Report on development status and investment strategy recommendations of global and Chinese graphite polystyrene board industry 2022-2028
我与CSDN的一年时光及大学经验分享
[tool sharing] a software that pays equal attention to appearance and skills
Wow, it's so rich.
Love Terminator
深入解析 Apache BookKeeper 系列:第三篇——读取原理
Kubernetes core components etcd details
活动报名|Apache Pulsar x KubeSphere 在线 Meetup 火热报名中
Your local changes to the following files would be overwritten by merge: . vs/slnx. sqlite
lotus v1.16.0-rc3 calibnet