In PL/SQL... why is it possible to name a variable (sysdate) although it's a reserved word?
for example,
set serveroutput on;
declare sysdate integer := 23;
begin
dbms_output.put_line(sysdate);
end;
which outputs: 23 and not the date of the current day.
Simply because
sysdate
is a SQL reserved word not PL/SQL. SQL and PL/SQL have different set of reserved words. Not all SQL reserved words are also PL/SQL reserved words and vice versa. So you may, although it's not recommended, use some SQL reserved words as identifiers in PL/SQL without enclosing them in double quotation marks:sysdate
and (say)add
are SQL reserved words, so we can use them as variables in PL/SQL without enclosing them in double quotation marks:Result:
But we cannot create a table that has column named
sysdate
oradd
:And vice versa. We cannot declare a PL/SQL variable (say)
if
without it being enclosed in double quotation marks, but we can easily create a table that has a column namedif
, becauseif
is PL/SQL reserved word not SQL:But when we put
if
in double quotation marks(try to avoid it) everything is going to be alright: