-- 变量名 数据类型() /*sales number(10, 2);*/ -- pi CONSTANT DOUBLE precision(精度) :=3.1414926 /*pi CONSTANT double precision := 3.1415; name varchar2(25); address varchar2(100);*/ -- pi CONSTANT NUMBER := 3.141592654; -- 编辑界面左上角有 SQL,输出,统计表三个标签,查看output要换到‘输出’的标签。 DECLARE -- constant declaration pi constant number := 3.141592654; -- other declarations radius number(5,2); dia number(5,2); circumference number(7, 2); area number (10, 2); BEGIN -- processing radius := 9.5; dia := radius * 2; circumference := 2.0 * pi * radius; area := pi * radius * radius; -- output dbms_output.put_line('Radius: ' || radius); dbms_output.put_line('Diameter: ' || dia); dbms_output.put_line('Circumference: ' || circumference); dbms_output.put_line('Area: ' || area); END; / /*Diameter: 19 Circumference: 59.69 Area: 283.53Radius: 9.5*/ DECLARE a number(2) := 10; BEGIN a:= 10; -- check the boolean condition using if statement IF( a < 20 ) THEN -- if condition is true then print the following dbms_output.put_line('a is less than 20 ' ); END IF; dbms_output.put_line('value of a is : ' || a); END; / /*a is less than 20 value of a is : 10*/ DECLARE a number(2) := 30; BEGIN a:= 30; -- check the boolean condition using if statement IF( a < 20 ) THEN -- if condition is true then print the following dbms_output.put_line('a is less than 20 ' ); ELSE dbms_output.put_line('a is greater than 20 ' ); END IF; dbms_output.put_line('value of a is : ' || a); END; / DECLARE i number(1); j number(1); BEGIN << outer_loop >> FOR i IN 1..3 LOOP << inner_loop >> FOR j IN 1..3 LOOP dbms_output.put_line('i is: '|| i || ' and j is: ' || j); END loop inner_loop; END loop outer_loop; END; /