这些 PL/SQL 变量初始化是否等效?

Are these PL/SQL variable initializations equivalent?

所以我知道我可以使用以下任一方法初始化 PL/SQL 中的变量:

例如:

这两种方法完全等同于PL/SQL引擎,还是有任何细微差别?

是的,它们是等价的。

来自Oracle documentation

You can use the keyword DEFAULT instead of the assignment operator to initialize variables. You can also use DEFAULT to initialize subprogram parameters, cursor parameters, and fields in a user-defined record.

Use DEFAULT for variables that have a typical value. Use the assignment operator for variables (such as counters and accumulators) that have no typical value.

Example 2-8 Assigning Default Values to Variables with DEFAULT Keyword

SQL> DECLARE
  2    blood_type CHAR DEFAULT 'O';         -- Same as blood_type CHAR := 'O';
  3  
  4    hours_worked    INTEGER DEFAULT 40;  -- Typical value
  5    employee_count  INTEGER := 0;        -- No typical value
  6  
  7  BEGIN
  8    NULL;
  9  END;
 10  /

PL/SQL procedure successfully completed.

SQL>

根据 the documentation,您可以使用:

To specify the initial value, use either the assignment operator (:=) or the keyword DEFAULT, followed by an expression

这意味着它们是等价的。