当前位置:网站首页>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文本字符串' | @ 局部变量名 | 字符串表达式 | @@ 函数名
边栏推荐
- Quick access to video links at station B
- Reviewer dis's whole research direction is not just reviewing my manuscript. What should I do?
- Word bag model and TF-IDF
- R语言做文本挖掘 Part4文本分类
- 【力扣刷题】32. 最长有效括号
- 对话阿里巴巴副总裁贾扬清:追求大模型,并不是一件坏事
- First batch selected! Tencent security tianyufeng control has obtained the business security capability certification of the ICT Institute
- SAP UI5 框架的 manifest.json
- MySQL - 事务(Transaction)详解
- b站视频链接快速获取
猜你喜欢

Reviewer dis's whole research direction is not just reviewing my manuscript. What should I do?

【论文解读】用于白内障分级/分类的机器学习技术

嵌入式开发的7大原罪

What is the problem with the SQL group by statement

After working for 5 years, this experience is left when you reach P7. You have helped your friends get 10 offers

对话阿里巴巴副总裁贾扬清:追求大模型,并不是一件坏事

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

MLP (multilayer perceptron neural network) is a multilayer fully connected neural network model.

20220211 failure - maximum amount of data supported by mongodb

Internet News: Geely officially acquired Meizu; Intensive insulin purchase was fully implemented in 31 provinces
随机推荐
分糖果
2017 8th Blue Bridge Cup group a provincial tournament
【mysql】触发器
R3live notes: image processing section
c#使用oracle存储过程获取结果集实例
【深度学习】PyTorch 1.12发布,正式支持苹果M1芯片GPU加速,修复众多Bug
js中,字符串和数组互转(一)——字符串转为数组的方法
@Detailed differences among getmapping, @postmapping and @requestmapping, with actual combat code (all)
JS according to the Chinese Alphabet (province) or according to the English alphabet - Za sort &az sort
爱可可AI前沿推介(7.6)
document. Usage of write () - write text - modify style and position control
快讯:飞书玩家大会线上举行;微信支付推出“教培服务工具箱”
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
3D face reconstruction: from basic knowledge to recognition / reconstruction methods!
技术分享 | 抓包分析 TCP 协议
JS learning notes OO create suspicious objects
El table table - get the row and column you click & the sort of El table and sort change, El table column and sort method & clear sort clearsort
Seven original sins of embedded development
2022 fields Award Announced! The first Korean Xu Long'er was on the list, and four post-80s women won the prize. Ukrainian female mathematicians became the only two women to win the prize in history
审稿人dis整个研究方向已经不仅仅是在审我的稿子了怎么办?