Block Types
匿名块是不存储在数据库里的, 有名块可以重复调用
set serveroutput on
declare
v_fname varchar2(20);
begin
select '111' into v_fname from dual;
dbms_output.put_line('The result '||v_fname );
end;
/
Requirements for Variable Names
1.must start with a letter
2.Can include letters or numbers
3.Can include special characters
4.Must contain no more than 30 characters
5.Must not include reserved words
Declaring an Initializing PL/SQL Variables
Types of Variables
PL/SQL variables:
1.Scalar 简单变量
2.Composite 复合变量
3.Reference 引用变量
4.Large object(LOB) 大对象
Non-PL/SQL variables: Bind variables 绑定变量
v_myName VARCHAR2(20):='John';
v_myName VARCHAR2(20) default 'John';
不要用列名来做变量名
Base Scalar Data Types
%TYPE Attribute
1.Is used to declare a variable according to:
A database column definition
Another declared variable
2.Is prefixed with
<