Oracle sql 中的'name'关键字是什么?



请解释这个" name "关键字这是什么?我们如何使用它?语法呢?

Oracle说这是一个关键字——一个具有特殊含义的标识符。

保留字相反,您可以使用关键字(包括name)来命名您自己的对象或变量,但不推荐使用. 例如:

SQL> create or replace procedure name as   --> procedure name is "name"
2    name varchar2(20);                  --> variable name is "name"
3  begin
4    null;
5  end;
6  /
Procedure created.
SQL>

作为保留字—例如,from是其中之一—您根本不能使用它们:

SQL> create or replace procedure from as    --> procedure name is "from"
2    from number;                         --> variable name is "from"
3  begin
4    null;
5  end;
6  /
create or replace procedure from as
*
ERROR at line 1:
ORA-04050: invalid or missing procedure, function, or package name

SQL> create or replace procedure test as  --> procedure name is fixed
2    from number;                       --> variable name is still "from"
3  begin
4    null;
5  end;
6  /
Warning: Procedure created with compilation errors.
SQL> show err
Errors for PROCEDURE TEST:
LINE/COL ERROR
-------- -----------------------------------------------------------------
2/3      PLS-00103: Encountered the symbol "FROM" when expecting one of
the following:
begin function pragma procedure subtype type <an identifier>
<a double-quoted delimited-identifier> current cursor delete
exists prior external language
The symbol "begin was inserted before "FROM" to continue.
5/4      PLS-00103: Encountered the sym
<snip>

为完整起见,可以使用保留字,如果您将它们括在双引号中,但这确实是您应该避免的:

SQL> create or replace procedure "from" as
2  begin
3    null;
4  end;
5  /
Procedure created.
SQL>

文档中的更多信息,例如PL/SQL保留词和关键字和保留词和关键字

最新更新