如何更改Oracle默认时间戳格式
使用 alter session 仅为当前会话设置 NLS_TIMESTAMP_FORMAT 或 NLS_TIMESTAMP_TZ_FORMAT。
它不会更改默认数据库属性。
我的机器上安装的 Oracle 10g 的语言环境设置为中文。并且时间戳格式是中文特有的。
我需要使用美国格式 (YYYY-MM-DD HH:MI:SS)。
有什么解决办法吗?
Using alter session only set NLS_TIMESTAMP_FORMAT or NLS_TIMESTAMP_TZ_FORMAT for the current session.
It does not change the default database properties.
The Oracle 10g's locale installed on my machine is set to Chinese. And the timestamp format is Chinese specific.
I need to use the US format (YYYY-MM-DD HH:MI:SS).
Any solution?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
来自Oracle文档:
您可以通过在初始化参数文件中设置NLS_TIMESTAMP_FORMAT来指定它的值。您可以将其值指定为客户端作为客户端环境变量。
您还可以通过更改初始化参数中的值来更改 NLS_TIMESTAMP_FORMAT 的值,然后重新启动实例。要在会话期间更改该值,请使用 ALTER SESSION SET 语句。
NLS_TIMESTAMP_FORMAT
http://download.oracle.com/docs/cd /B19306_01/server.102/b14237/initparams132.htm
和NLS_TIMESTAMP_TZ_FORMAT:
http://download.oracle.com/docs/cd /B19306_01/server.102/b14237/initparams133.htm
您需要更改实例的参数并反弹数据库。
From the Oracle documentation:
You can specify the value of NLS_TIMESTAMP_FORMAT by setting it in the initialization parameter file. You can specify its value for a client as a client environment variable.
You can also alter the value of NLS_TIMESTAMP_FORMAT by changing its value in the initialization parameter and then restarting the instance. To alter the value during a session use the ALTER SESSION SET statement.
NLS_TIMESTAMP_FORMAT
http://download.oracle.com/docs/cd/B19306_01/server.102/b14237/initparams132.htm
and for NLS_TIMESTAMP_TZ_FORMAT:
http://download.oracle.com/docs/cd/B19306_01/server.102/b14237/initparams133.htm
You'll need to alter the instance's paramters and bounce the database.
哦。我打开了两个选项卡,并将其放在错误的线程中...
要在数据库中永久设置默认值,从数据库:
然后作为 SYS(因此您可能需要与 DBA 交谈),并且显然是在适当的时间! -
(我知道已经提到了 spfile,但是这一切都可以从 sqlplus cmdline 完成,至少在版本 11g 中是这样。)
Doh. I had two tabs open and put this in the wrong thread...
To set the default permanently in the database, from the database:
then as SYS (so you may need to talk to a DBA), and obviously at an appropriate time! -
(I know the spfile has been mentioned, but it can all be done from the sqlplus cmdline, at least in version 11g.)