pl/sql中的注释

来源:这里教程网 时间:2026-03-03 12:07:14 作者:

一、注释分为单行注释和多行注释两种。     1.单行注释使用“--”。         DECLARE         howmany NUMBER;         num_tables NUMBER;         BEGIN         -- Begin processing         SELECT COUNT(*) INTO howmany         FROM USER_OBJECTS         WHERE OBJECT_TYPE = 'TABLE';     -- Check number of tables         num_tables := howmany; -- Compute another value         END;     2.多行注释以“/*”开始,“*/”结尾。         DECLARE         some_condition BOOLEAN;         pi NUMBER := 3.1415926;         radius NUMBER := 15;         area NUMBER;         BEGIN         /* Perform some simple tests and assignments */         IF 2 + 2 = 4 THEN         some_condition := TRUE;         /* We expect this THEN to always be performed */         END IF;         /* This line computes the area of a circle using pi,         which is the ratio between the circumference and diameter.         After the area is computed, the result is displayed. */         area := pi * radius**2;         DBMS_OUTPUT.PUT_LINE('The area is: ' || TO_CHAR(area));         END; 二、使用注释需要注意点     1.多行注释不能进行嵌套,如下面是错误的:          /*         IF 2 + 2 = 4 THEN         some_condition := TRUE;         /* We expect this THEN to always be performed */         END IF;         */     2.多行注释里面可以嵌套单行注释:         /*         IF 2 + 2 = 4 THEN         some_condition := TRUE;         -- We expect this THEN to always be performed         END IF;         */

相关推荐