Oracle中的关键字 保留字

2014-11-24 18:24:26 · 作者: · 浏览: 0

Reserved words and keywordsare identifiers that have special meaning in PL/SQL.


You cannot use reserved words as ordinary user-defined identifiers. You can use them as quoted user-defined identifiers, but it is not recommended. For more information, see"QuotedUser-Defined Identifiers".


You can use keywords as ordinary user-defined identifiers,but it is not recommended.


不能使用保留字作为用户定义的变量。但是当加上双引号就可以,但是不推存。


关键字就可以作为用户定义的变量,但是不推存。


举例子:


(1)保留字


-- number


创建表,作为字段名。


SQL> CREATE TABLE cux_oyj_RESERVED_WORDS(NUMBER NUMBER);


CREATE TABLE cux_oyj_RESERVED_WORDS(NUMBER NUMBER)


ORA-00904: : 标识符无效


加上双引号,就可以


SQL> CREATE TABLE cux_oyj_RESERVED_WORDS("NUMBER" NUMBER);


Table created


但是查询:


SQL> SELECT rw.number from cux_oyj_RESERVED_WORDS rw;


SELECT rw.number from cux_oyj_RESERVED_WORDS rw


ORA-01747: user.table.column, table.column 或列说明无效


使用起来比较麻烦。


(2)关键字


--name


创建表,作为字段名。


SQL> CREATE TABLE cux_oyj_KEYWORDS(NAME VARCHAR2(50));


Table created


保留字与关键字的视图(动态视图)V$RESERVED_WORDS


This view gives a list of all SQL keywords. To determine whether a particular keyword is reserved in any way, check the RESERVED, RES_TYPE, RES_ATTR, and RES_SEMI columns.


保留字:


关键字: