Oracle 保留字和关键字

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.

Column Datatype Description
KEYWORD VARCHAR2(30) Name of the keyword
LENGTH NUMBER Length of the keyword
RESERVED VARCHAR2(1) A value of Y means that the keyword cannot be used as an identifier. A value of N means that it is not reserved.
RES_TYPE VARCHAR2(1) A value of Y means that the keyword cannot be used as a type name. A value of N means that it is not reserved.
RES_ATTR VARCHAR2(1) A value of Y means that the keyword cannot be used as an attribute name. A value of N means that it is not reserved.
RES_SEMI VARCHAR2(1) A value of Y means that the keyword is not allowed as an identifier in certain situations, such as in DML. A value of N means that it is not reserved.
DUPLICATE VARCHAR2(1) A value of Y means that the keyword is a duplicate of another keyword. A value of N means that it is not a duplicate.

保留字:

Begins with: Reserved Words
A
ALL, ALTER, AND, ANY, AS, ASC, AT

B
BEGIN, BETWEEN, BY

C
CASE, CHECK, CLUSTERS, CLUSTER, COLAUTH, COLUMNS, COMPRESS, CONNECT, CRASH, CREATE, CURSOR

D
DECLARE, DEFAULT, DESC, DISTINCT, DROP

E
ELSE, END, EXCEPTION, EXCLUSIVE

F
FETCH, FOR, FROM, FUNCTION

G
GOTO, GRANT, GROUP

H
HAVING

I
IDENTIFIED, IF, IN, INDEX, INDEXES, INSERT, INTERSECT, INTO, IS

L
LIKE, LOCK

M
MINUS, MODE

N
NOCOMPRESS, NOT, NOWAIT, NULL

O
OF, ON, OPTION, OR, ORDER, OVERLAPS

P
PROCEDURE, PUBLIC

R
RESOURCE, REVOKE

S
SELECT, SHARE, SIZE, SQL, START, SUBTYPE

T
TABAUTH, TABLE, THEN, TO, TYPE

U
UNION, UNIQUE, UPDATE

V
VALUES, VIEW, VIEWS

W
WHEN, WHERE, WITH


关键字:

Begins with: Keywords
A
A, ADD, AGENT, AGGREGATE, ARRAY, ATTRIBUTE, AUTHID, AVG

B
BFILE_BASE, BINARY, BLOB_BASE, BLOCK, BODY, BOTH, BOUND, BULK, BYTE

C
C, CALL, CALLING, CASCADE, CHAR, CHAR_BASE, CHARACTER, CHARSET, CHARSETFORM, CHARSETID, CLOB_BASE, CLOSE, COLLECT, COMMENT, COMMIT, COMMITTED, COMPILED, CONSTANT, CONSTRUCTOR, CONTEXT, CONTINUE, CONVERT, COUNT, CURRENT, CUSTOMDATUM

D
DANGLING, DATA, DATE, DATE_BASE, DAY, DEFINE, DELETE, DETERMINISTIC, DOUBLE, DURATION

E
ELEMENT, ELSIF, EMPTY, ESCAPE, EXCEPT, EXCEPTIONS, EXECUTE, EXISTS, EXIT, EXTERNAL

F
FINAL, FIXED, FLOAT, FORALL, FORCE

G
GENERAL

H
HASH, HEAP, HIDDEN, HOUR

I
IMMEDIATE, INCLUDING, INDICATOR, INDICES, INFINITE, INSTANTIABLE, INT, INTERFACE, INTERVAL, INVALIDATE, ISOLATION

J
JAVA

L
LANGUAGE, LARGE, LEADING, LENGTH, LEVEL, LIBRARY, LIKE2, LIKE4, LIKEC, LIMIT, LIMITED, LOCAL, LONG, LOOP

M
MAP, MAX, MAXLEN, MEMBER, MERGE, MIN, MINUTE, MOD, MODIFY, MONTH, MULTISET

N
NAME, NAN, NATIONAL, NATIVE, NCHAR, NEW, NOCOPY, NUMBER_BASE

O
OBJECT, OCICOLL, OCIDATE, OCIDATETIME, OCIDURATION, OCIINTERVAL, OCILOBLOCATOR, OCINUMBER, OCIRAW, OCIREF, OCIREFCURSOR, OCIROWID, OCISTRING, OCITYPE, OLD, ONLY, OPAQUE, OPEN, OPERATOR, ORACLE, ORADATA, ORGANIZATION, ORLANY, ORLVARY, OTHERS, OUT, OVERRIDING

P
PACKAGE, PARALLEL_ENABLE, PARAMETER, PARAMETERS, PARENT, PARTITION, PASCAL, PIPE, PIPELINED, PRAGMA, PRECISION, PRIOR, PRIVATE

R
RAISE, RANGE, RAW, READ, RECORD, REF, REFERENCE, RELIES_ON, REM, REMAINDER, RENAME, RESULT, RESULT_CACHE, RETURN, RETURNING, REVERSE, ROLLBACK, ROW

S
SAMPLE, SAVE, SAVEPOINT, SB1, SB2, SB4, SECOND, SEGMENT, SELF, SEPARATE, SEQUENCE, SERIALIZABLE, SET, SHORT, SIZE_T, SOME, SPARSE, SQLCODE, SQLDATA, SQLNAME, SQLSTATE, STANDARD, STATIC, STDDEV, STORED, STRING, STRUCT, STYLE, SUBMULTISET, SUBPARTITION, SUBSTITUTABLE, SUM, SYNONYM

T
TDO, THE, TIME, TIMESTAMP, TIMEZONE_ABBR, TIMEZONE_HOUR, TIMEZONE_MINUTE, TIMEZONE_REGION, TRAILING, TRANSACTION, TRANSACTIONAL, TRUSTED

U
UB1, UB2, UB4, UNDER, UNSIGNED, UNTRUSTED, USE, USING

V
VALIST, VALUE, VARIABLE, VARIANCE, VARRAY, VARYING, VOID

W
WHILE, WORK, WRAPPED, WRITE

Y
YEAR

Z
ZONE

你可能感兴趣的:(oracle)