What is the difference between := and = in Oracle PL/SQL

25.3k Views Asked by At

I want to know in Oracle PL/SQL,

= can be used for Boolean comparison, can it be used for assignment as well?

While is := used for variable initialization, can it be used for assignment too?

Then, so what is the difference between the use of 2?

Thanks!

2

There are 2 best solutions below

1
On

General declaration syntax in PL/SQL uses ':='.Look below

variable_name datatype [NOT NULL := value ];

where, variable_name is the name of the variable. datatype is a valid PL/SQL datatype. NOT NULL is an optional specification on the variable. value or DEFAULT value is also an optional specification, where you can initialize a variable. Each variable declaration is a separate statement and must be terminated by a semicolon.

'=' is the normal operator that we use in any other language

0
On

= is the equality comparison operator, both in PL/SQL and SQL. := is the PL/SQL value assignment operator.

These are analogous to == and = in C-derived languages.

Share and enjoy.