子类型具有与其基本类型相同的操作,但只有基本类型有效值的子集。
例如,pl/sql预先定义子类型character
和integer
,如下所示:
subtype character is char; subtype integer is number(38,0);
并且,可以定义和使用自己的子类型:
declare subtype name is char(20); subtype message is varchar2(100); salutation name; greetings message; begin salutation := 'reader '; greetings := 'welcome to the world of pl/sql'; dbms_output.put_line('hello ' || salutation || greetings); end; 输出结果: hello reader welcome to the world of pl/sql