[20171218]欄位命名與oracle關鍵字.txt

lfree發表於2017-12-18

[20171218]欄位命名與oracle關鍵字.txt

--//再次提醒開發應該在資料庫欄位命令上避開oracle關鍵字(保留字).避免出現混亂.

SCOTT@book> @ &r/ver1
PORT_STRING                    VERSION        BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx            11.2.0.4.0     Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

SCOTT@book> create table t2 ( user varchar2(20));
create table t2 ( user varchar2(20))
                  *
ERROR at line 1:
ORA-00904: : invalid identifier
--//user是保留字.

SCOTT@book> create table t2 ( "USER" varchar2(20));
Table created.

SCOTT@book> insert into t2 values ('aaaa');
1 row created.

SCOTT@book> commit ;
Commit complete.

SCOTT@book> select user from t2;
USER
------
SCOTT
--//返回當前使用者名稱.

SCOTT@book> select user,"USER" from t2;
USER   USER
------ -----
SCOTT  aaaa

SCOTT@book> select * from v$reserved_words where KEYWORD='USER' ;
KEYWORD                            LENGTH R R R R D
------------------------------ ---------- - - - - -
USER                                    4 N N N Y N

--//參考連結:http://blog.itpub.net/267265/viewspace-2142685/

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2148822/,如需轉載,請註明出處,否則將追究法律責任。

相關文章