修改oracle 數據庫默認時間格式


原網址:http://blog.itpub.net/28587920/viewspace-759815/

 

突然想修改下oracle默認的時間格式,在論壇搜索了一大圈,嘗試了很多答案,發現都是謬論,以下是oracle在linux環境下的解決方案。

linux下通過修改spfile文件可以解決,跟環境變量 NLS_DATE_FORMAT毛關系都沒有。另外,也測試了windows下只跟環境變量NLS_DATE_FORMAT有關系,跟spfile無關。

今天還搜索到一種方式,通過修改oracle參數文件$ORACLE_HOME/dbs/inita.ora來實現,未驗證通過,但按原理來說應該是可以的。這么一個簡簡單單的問題,耗費了我大量時間啊,一切都是不明白oracle體系結構,執行機制而產生的,要努力掌握這一塊!!。

實驗環境:linux+oracle 10.2.0.1

                 windows+oracle 10.2.0.5

[oracle@gzsjmp ~]$ sqlplus sys/haitao88 as sysdba;

SQL*Plus: Release 10.2.0.1.0 - Production on Sun Mar 3 16:02:27 2013

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


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

SQL> select sysdate from dual;

SYSDATE
----------
2013-03-03


SQL> alter system set nls_date_format='YYYY-MM-DD hh24:mi:ss' scope=spfile;

System altered.

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup;
ORACLE instance started.

Total System Global Area  599785472 bytes
Fixed Size                  2022632 bytes
Variable Size             234881816 bytes
Database Buffers          360710144 bytes
Redo Buffers                2170880 bytes
Database mounted.
Database opened.
SQL> select sysdate from dual;

SYSDATE
-------------------
2013-03-03 16:04:38

SQL> show parameters nls

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
nls_calendar                         string
nls_comp                             string
nls_currency                         string
nls_date_format                      string      YYYY-MM-DD hh24:mi:ss
nls_date_language                    string

SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
[oracle@gzsjmp ~]$  echo $NLS_DATE_FORMAT;
YYYY-MM-DD


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM