小布老师—PL_SQL(第三讲)

本文深入探讨了PL_SQL中变量的定义与使用,包括标量、复合型、引用变量及大变量,同时介绍了如何声明布尔型变量、绑定变量,并提供了实例演示。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.dos 下清屏 clear scr

一、PL_SQL变量定义

1.Scalar 标量-最简单的变量使用最刚

2.Composite 复合型变量-

3.Reference 引用变量

4.LOB  大变量音频,视频等

5.Bind variables 不是PL_SQL变量是环境变量

二、注意事项

1.每一行定义一个变量,注意缩进;

2.避免定义与列名相同的变量;

三、Scalar变量

1.Hold a single value

2.Have no internal components

四、%TYPE   Attibute

1.Is used  to declare a variable according to :

        - A database column definition

        - Another declared variable

2.Is prefixed with( prefixe 前缀 )

        - The database table and column

        -  The name of the declared variable

3.语法

indetifier   table.column_name % TYPE;

4.example

min_balance   balance%type := 1000;

五、Declaring Boolean Variables (boolean 型变量)

only the true、false、and null values can be assigened to a boolean variable;

六、Bind Variables(绑定变量)

1.Created in the environment;

2.Also called host variables;

3.EXAMPLE

variable b_emp_salary number;

begin

         select salary into :b_emp_salary from employees where employee_id  = 179;

end;

/

print b_emp_salary;

select first_name ,last_name from employees where salary=:b_emp_salary;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值