当前位置:网站首页>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文本字符串' | @ 局部变量名 | 字符串表达式 | @@ 函数名
边栏推荐
- PG basics -- Logical Structure Management (transaction)
- JS学习笔记-OO创建怀疑的对象
- 对话阿里巴巴副总裁贾扬清:追求大模型,并不是一件坏事
- Data Lake (VIII): Iceberg data storage format
- 审稿人dis整个研究方向已经不仅仅是在审我的稿子了怎么办?
- KDD 2022 | 通过知识增强的提示学习实现统一的对话式推荐
- 966 minimum path sum
- [Li Kou brushing questions] one dimensional dynamic planning record (53 change exchanges, 300 longest increasing subsequence, 53 largest subarray and)
- PHP saves session data to MySQL database
- One line by line explanation of the source code of anchor free series network yolox (a total of ten articles, you can change the network at will after reading it, if you won't complain to me)
猜你喜欢

Internet News: Geely officially acquired Meizu; Intensive insulin purchase was fully implemented in 31 provinces

Common English vocabulary that every programmer must master (recommended Collection)

袁小林:安全不只是标准,更是沃尔沃不变的信仰和追求

基于深度学习的参考帧生成

3D face reconstruction: from basic knowledge to recognition / reconstruction methods!

OneNote 深度评测:使用资源、插件、模版

Aike AI frontier promotion (7.6)
![[MySQL] trigger](/img/b5/6df17eb254bbdb0aba422d08f13046.png)
[MySQL] trigger

PHP saves session data to MySQL database

Set up a time server
随机推荐
[Li Kou brushing questions] one dimensional dynamic planning record (53 change exchanges, 300 longest increasing subsequence, 53 largest subarray and)
How to implement common frameworks
El table table - sortable sorting & disordered sorting when decimal and% appear
None of the strongest kings in the monitoring industry!
[sliding window] group B of the 9th Landbridge cup provincial tournament: log statistics
监控界的最强王者,没有之一!
Divide candy
The use method of string is startwith () - start with XX, endswith () - end with XX, trim () - delete spaces at both ends
el-table表格——获取单击的是第几行和第几列 & 表格排序之el-table与sort-change、el-table-column与sort-method & 清除排序-clearSort
Regular expression collection
Manifest of SAP ui5 framework json
Math symbols in lists
Word bag model and TF-IDF
HMS Core 机器学习服务打造同传翻译新“声”态,AI让国际交流更顺畅
JS operation DOM element (I) -- six ways to obtain DOM nodes
MLP (multilayer perceptron neural network) is a multilayer fully connected neural network model.
Opencv learning example code 3.2.3 image binarization
Chris LATTNER, the father of llvm: why should we rebuild AI infrastructure software
【mysql】游标的基本使用
Study notes of grain Mall - phase I: Project Introduction