nls引數、環境變數以及函式等起作用的順序!

warehouse發表於2009-07-29

nls引數、環境變數以及函式起作用的順序是:

instance級引數---&gtnls_lang---&gtsession級引數---&gt函式。

[@more@]

C:>set nls_lang=SIMPLIFIED CHINESE_CHINA.ZHS16GBK

C:>sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on 星期三 7月 29 21:01:38 2009

Copyright (c) 1982, 2005, Oracle. All rights reserved.


連線到:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL> show parameter nls_date_format

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
nls_date_format string yyyy/mm/dd hh24:mi:ss
--很明顯例項級別引數nls_date_format沒有啟作用
SQL> select sysdate from dual;

SYSDATE
--------------
29-7月 -09
--==============================
--在登錄檔中清除nls_lang的值,這是我們發現例項級引數nls_date_format:格式
yyyy/mm/dd hh24:mi:ss開始發揮作用
SQL> exit
從 Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options 斷開

C:>sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Wed Jul 29 20:54:59 2009

Copyright (c) 1982, 2005, Oracle. All rights reserved.


???:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

SQL> select sysdate from dual;

SYSDATE
-------------------
2009/07/29 20:55:01
--====================================
--恢復登錄檔中的nls_lang設定:SIMPLIFIED CHINESE_CHINA.ZHS16GBK
SQL> exit
? Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options ??

C:>sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on 星期三 7月 29 20:55:21 2009

Copyright (c) 1982, 2005, Oracle. All rights reserved.


連線到:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

SQL> select sysdate from dual;

SYSDATE
--------------
29-7月 -09

SQL> alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';

會話已更改。
--顯然session級別的nls_date_format發揮了作用
SQL> select sysdate from dual;

SYSDATE
-------------------
2009-07-29 20:55:55
--很顯然函式發揮了作用
SQL> select to_char(sysdate,'yyyy-mm-dd hh:mi:ss') from dual;

TO_CHAR(SYSDATE,'YY
-------------------
2009-07-29 09:10:01

SQL>

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

相關文章