修改資料庫的日期顯示格式

zhyuh發表於2005-07-01
資料庫移植後,程式裡的所有類似insert into table (aaa_date) values('20050101')的語句都執行失敗,原因是日期格式發生了變化。[@more@]

1。SQL> alter session set nls_date_format='yyyymmdd';

Session altered

SQL> alter system set nls_date_format='yyyymmdd';

alter system set nls_date_format='yyyymmdd'

ORA-02096: specified initialization parameter is not modifiable with this option

2。 修改.profile檔案,增加引數export nls_date_format='yyyymmdd',執行該檔案並重新啟動資料庫例項,失敗,日期仍為原來格式

3。spfile裡增加引數nls_date_format='yyyymmdd',仍失敗

4。用trigger

SQL> create or replace trigger SetDate AFTER Logon On Database
2 Begin
3 Execute Immediate 'Alter Session set NLS_DATE_FORMAT = ''YYYYMMDD''';
4 END;
5 /

OK

問題算繞過去了,但是如果不用trigger,能不能修改資料庫日期格式呢?還不是很確定。

有高手路過請給個答案或提示。謝謝!

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

相關文章