当前位置:网站首页>SQL:存储过程和触发器~笔记
SQL:存储过程和触发器~笔记
2022-07-06 13:07:00 【念迟鱼学编程】
1.变量的概念分类
概念 :被赋予一定值的语言元素。
分类:全局变量、局部变量
全局变量 | 由系统提供并且预先声明的变量,用户一般只能查看不能修改全局变量的值,一般是以@@开始的变量 |
---|---|
局部变量 | 用户声明的用以保存特定类型的单个数据值的对象。它局部于一个语句批,一般是以@开始的变量 |
2.变量的声明与赋值
局部变量必须先声明再使用,声明的基本语句:
declare @ 局部变量 [as] 数据类型 [,......n]
注意:使用declare语句声明的局部变量初始值被初始化为NULL。
变量赋值语句格式:
set @ 局部变量名 = 值 | 表达式
注意:表达式可以是任何SQL表达式
也可以使用select语句对局部变量赋值,格式为:
select @ 局部变量 = 值 | 表达式
例题:声明三个整型变量:@x、@y和@z,并给@x、@y变量分别赋予一个初值,然后将这两个变量的和值赋给@z,并显示变量@z的结果。
declare @x int , @y int , @z int
set @x = 10
set @y = 20
set @z = @x + @y
print @z
print的作用是将用户定义的信息返回给客户端,其语法格式为:
print 'ascll文本字符串' | @ 局部变量名 | 字符串表达式 | @@ 函数名
边栏推荐
- Nodejs教程之让我们用 typescript 创建你的第一个 expressjs 应用程序
- [sliding window] group B of the 9th Landbridge cup provincial tournament: log statistics
- How to implement common frameworks
- 20220211 failure - maximum amount of data supported by mongodb
- JS operation DOM element (I) -- six ways to obtain DOM nodes
- 3D人脸重建:从基础知识到识别/重建方法!
- js中,字符串和数组互转(一)——字符串转为数组的方法
- js之遍历数组、字符串
- @GetMapping、@PostMapping 和 @RequestMapping详细区别附实战代码(全)
- Replace Internet TV set-top box application through digital TV and broadband network
猜你喜欢
OneNote in-depth evaluation: using resources, plug-ins, templates
MLP (multilayer perceptron neural network) is a multilayer fully connected neural network model.
监控界的最强王者,没有之一!
OneNote 深度评测:使用资源、插件、模版
缓存更新策略概览(Caching Strategies Overview)
Set up a time server
Aiko ai Frontier promotion (7.6)
967- letter combination of telephone number
Swagger UI tutorial API document artifact
This year, Jianzhi Tencent
随机推荐
Vim 基本配置和经常使用的命令
[Li Kou brushing questions] one dimensional dynamic planning record (53 change exchanges, 300 longest increasing subsequence, 53 largest subarray and)
袁小林:安全不只是标准,更是沃尔沃不变的信仰和追求
FZU 1686 龙之谜 重复覆盖
Is it profitable to host an Olympic Games?
[MySQL] trigger
首批入选!腾讯安全天御风控获信通院业务安全能力认证
R語言可視化兩個以上的分類(類別)變量之間的關系、使用vcd包中的Mosaic函數創建馬賽克圖( Mosaic plots)、分別可視化兩個、三個、四個分類變量的關系的馬賽克圖
document. Usage of write () - write text - modify style and position control
968 edit distance
js之遍历数组、字符串
js中,字符串和数组互转(一)——字符串转为数组的方法
Quick news: the flybook players' conference is held online; Wechat payment launched "education and training service toolbox"
Yyds dry inventory run kubeedge official example_ Counter demo counter
Start the embedded room: system startup with limited resources
通过数字电视通过宽带网络取代互联网电视机顶盒应用
[Li Kou brush questions] 32 Longest valid bracket
跨分片方案 总结
JS traversal array and string
Select data Column subset in table R [duplicate] - select subset of columns in data table R [duplicate]