修改数据库的日期显示格式

数据库移植后,程序里的所有类似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,能不能修改数据库日期格式呢?还不是很确定。

有高手路过请给个答案或提示。谢谢!

请使用浏览器的分享功能分享到微信等