PL SQL中声明时变量的默认值

7 sql oracle plsql

VARCHAR2在PL/SQL中声明时变量的默认值是多少?NULL在声明变量后,我可以检查一次吗?

tui*_*oel 21

变量默认使用NULL初始化.

您可以更改它,例如:

create procedure show1
as
  l_start varchar2(10) := 'Hello';
begin
  if l_start is not null then 
    ....
  end if;
end;
/
Run Code Online (Sandbox Code Playgroud)

您还可以将变量声明为不可为空:

create procedure show2
as
  l_start varchar2(10) not null := 'Hello';
begin
  null;
end;
/
Run Code Online (Sandbox Code Playgroud)


And*_*int 2

默认值为 NULL,您可以使用 IS NULL 或 IS NOT NULL。