当前位置:网站首页>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文本字符串' | @ 局部变量名 | 字符串表达式 | @@ 函数名
边栏推荐
- 2022菲尔兹奖揭晓!首位韩裔许埈珥上榜,四位80后得奖,乌克兰女数学家成史上唯二获奖女性
- 愛可可AI前沿推介(7.6)
- Nodejs教程之让我们用 typescript 创建你的第一个 expressjs 应用程序
- Vim 基本配置和经常使用的命令
- R language visualizes the relationship between more than two classification (category) variables, uses mosaic function in VCD package to create mosaic plots, and visualizes the relationship between tw
- Word bag model and TF-IDF
- Le langage r visualise les relations entre plus de deux variables de classification (catégories), crée des plots Mosaiques en utilisant la fonction Mosaic dans le paquet VCD, et visualise les relation
- [Li Kou brushing questions] one dimensional dynamic planning record (53 change exchanges, 300 longest increasing subsequence, 53 largest subarray and)
- Manifest of SAP ui5 framework json
- In JS, string and array are converted to each other (I) -- the method of converting string into array
猜你喜欢
Summary of cross partition scheme
OneNote 深度评测:使用资源、插件、模版
Common English vocabulary that every programmer must master (recommended Collection)
快讯:飞书玩家大会线上举行;微信支付推出“教培服务工具箱”
防火墙基础之外网服务器区部署和双机热备
Quick news: the flybook players' conference is held online; Wechat payment launched "education and training service toolbox"
3D face reconstruction: from basic knowledge to recognition / reconstruction methods!
[sliding window] group B of the 9th Landbridge cup provincial tournament: log statistics
Fastjson parses JSON strings (deserialized to list, map)
Aike AI frontier promotion (7.6)
随机推荐
爱可可AI前沿推介(7.6)
R language for text mining Part4 text classification
互联网快讯:吉利正式收购魅族;胰岛素集采在31省全面落地
OSPF multi zone configuration
ICML 2022 | flowformer: task generic linear complexity transformer
SAP UI5 框架的 manifest.json
Pat 1078 hashing (25 points) ⼆ times ⽅ exploration method
[interpretation of the paper] machine learning technology for Cataract Classification / classification
Technology sharing | packet capturing analysis TCP protocol
Internet News: Geely officially acquired Meizu; Intensive insulin purchase was fully implemented in 31 provinces
Math symbols in lists
启动嵌入式间:资源有限的系统启动
MySQL - 事务(Transaction)详解
Summary of cross partition scheme
Swagger UI tutorial API document artifact
FZU 1686 龙之谜 重复覆盖
通过数字电视通过宽带网络取代互联网电视机顶盒应用
What is the problem with the SQL group by statement
[MySQL] trigger
MLP (multilayer perceptron neural network) is a multilayer fully connected neural network model.