当前位置:网站首页>MYSQL中变量的操作
MYSQL中变量的操作
2022-07-20 00:29:00 【DanceDonkey】
变量分为系统变量和用户自定义变量,顾名思义,系统变量就是系统定义好的一些变量,这些变量是固定的,而用户变量不是固定的,用户可以根据需求来定义且使用。
- 系统变量
系统变量又分为全局系统变量和会话系统变量,全局系统变量的修改影响所有的会话,而会话变量的修改只影响当前会话。
- 查看系统变量
show global variables
- 查看时筛选
show global variables like '%char%'
- 查看会话变量
show session variables
注意:如果global或是session省略,则默认是会话变量
- 查看某个特定的变量
select @@global.max_connections;
系统变量以连个@开头,@@后面是global为查看系统变量,@@后面是session是查看会话变量。
- 修改变量的值
set @@global .max_connections = 3000;
再次查看
用户变量
用户会话变量,用户声明以后,只要当前连接不关闭,就会一直保存在服务器内存中,会话与会话之前变量有隔离性。
- 用户会话变量定义
set @count = 0;
set @count := 1;
select @count;
- 定义用户变量,批量更新sql
set @indexcount := 0;
update emp set count = (@indexcount := @indexcount + 1);
select *
from emp;
- 用户自定义变量只能用在begin end 中 暂不讲述。
边栏推荐
- 2022.7.19-----leetcode.731
- Office sharing and collaboration methods -- the correct way to open office sharing, office365 white whoring
- Zero Path
- 144. Preorder traversal of binary tree
- Matlab tutorial_ Summary of guoyanfu's notes at National Taiwan University (with video materials attached)
- Circle Game
- Component architecture project construction - gradle unified, dependent management and configuration
- linux上redis升级
- DBeaver的操作日志
- Dest0g3 520迎新赛web
猜你喜欢
游戏公司的越冬样本:出海和精品化成为新的增长点?
第八章:区间[ %d,%d]内等差素数列,改进等差素数列
Installation de MySQL par centos8
软件测试知识库+1,5款顶级自动化测试工具推荐和使用分析
组件化架构项目搭建——Gradle统一、依赖管理与配置
EasyCVR接入国标GB28181设备,通道没有音频是什么原因?
外表简单内里复杂的功能测试,如何进行?
Edge 开发者沙龙|一小时精通Edge扩展开发
Apipost :一款值得使用的利器
What does the performance test report include? Where can I find the template? Look here
随机推荐
软件性能测试方案-性能测试准备
SweetAlert笔记-在弹窗中添加输入框图片等
Qu'est - ce qu'un conflit de réplication
哔哩哔哩 直播分区页面 自动检索红包直播间并跳转
Surprise! Nearly 2million depositors' deposits were stolen by "face swiping". Look at your bank card. Are there these three kinds of risks?
2022 Hangdian Zhongchao
EasyCVR配置RTMP推流后重启导致RTMP离线该如何解决?
Helm introduction
Unable to install cloudera manager agent
第八章:区间[ %d,%d]内等差素数列,改进等差素数列
What does the performance test report include? Where can I find the template? Look here
cpolar应用实例之助力航运客户远程办公
Introduction to kubernetes components
企业应积极探索,把握元宇宙新业态与新趋势
tidb-读热点造成的单kv负载高
Edge 开发者沙龙|一小时精通Edge扩展开发
Cve-2014-6271 "broken shell" vulnerability
读书记录 《大脑保养刻不容缓》
About authorizingrealm unable to inject service
AI常用框架和工具丨13. PyTorch实现基于CNN的手写数字识别