oracle中的关键字和保留字


文章来自:http://blog.csdn.net/jieouyang/article/details/8260429

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

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


举例子:

(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 RESERVEDRES_TYPERES_ATTR, and RES_SEMI columns.

ColumnDatatypeDescription
KEYWORDVARCHAR2(30)Name of the keyword
LENGTHNUMBERLength of the keyword
RESERVEDVARCHAR2(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_TYPEVARCHAR2(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_ATTRVARCHAR2(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_SEMIVARCHAR2(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.
DUPLICATEVARCHAR2(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


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值