当前位置:网站首页>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文本字符串' | @ 局部变量名 | 字符串表达式 | @@ 函数名
边栏推荐
- None of the strongest kings in the monitoring industry!
- 20220211 failure - maximum amount of data supported by mongodb
- The most comprehensive new database in the whole network, multidimensional table platform inventory note, flowus, airtable, seatable, Vig table Vika, flying Book Multidimensional table, heipayun, Zhix
- 3D人脸重建:从基础知识到识别/重建方法!
- for循环中break与continue的区别——break-完全结束循环 & continue-终止本次循环
- 监控界的最强王者,没有之一!
- JS operation DOM element (I) -- six ways to obtain DOM nodes
- 爱可可AI前沿推介(7.6)
- 【力扣刷题】一维动态规划记录(53零钱兑换、300最长递增子序列、53最大子数组和)
- 互联网快讯:吉利正式收购魅族;胰岛素集采在31省全面落地
猜你喜欢
互联网快讯:吉利正式收购魅族;胰岛素集采在31省全面落地
[in depth learning] pytorch 1.12 was released, officially supporting Apple M1 chip GPU acceleration and repairing many bugs
爱可可AI前沿推介(7.6)
Absolute primes (C language)
ICML 2022 | Flowformer: 任务通用的线性复杂度Transformer
[MySQL] basic use of cursor
对话阿里巴巴副总裁贾扬清:追求大模型,并不是一件坏事
Reviewer dis's whole research direction is not just reviewing my manuscript. What should I do?
审稿人dis整个研究方向已经不仅仅是在审我的稿子了怎么办?
MLP (multilayer perceptron neural network) is a multilayer fully connected neural network model.
随机推荐
Binary tree node at the longest distance
Yyds dry inventory run kubeedge official example_ Counter demo counter
Quick news: the flybook players' conference is held online; Wechat payment launched "education and training service toolbox"
Manifest of SAP ui5 framework json
What's the best way to get TFS to output each project to its own directory?
Seven original sins of embedded development
跨分片方案 总结
El table table - sortable sorting & disordered sorting when decimal and% appear
Three schemes of SVM to realize multi classification
'class file has wrong version 52.0, should be 50.0' - class file has wrong version 52.0, should be 50.0
Study notes of grain Mall - phase I: Project Introduction
Data Lake (VIII): Iceberg data storage format
通过数字电视通过宽带网络取代互联网电视机顶盒应用
【力扣刷题】一维动态规划记录(53零钱兑换、300最长递增子序列、53最大子数组和)
Chris LATTNER, the father of llvm: why should we rebuild AI infrastructure software
面试官:Redis中有序集合的内部实现方式是什么?
JS traversal array and string
Swagger UI教程 API 文档神器
3D face reconstruction: from basic knowledge to recognition / reconstruction methods!
KDD 2022 | realize unified conversational recommendation through knowledge enhanced prompt learning