如何更改 Oracle 默认时间戳格式
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7147945/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to change the Oracle default timestamp format
提问by xiaohan2012
Using alter session only set NLS_TIMESTAMP_FORMATor NLS_TIMESTAMP_TZ_FORMATfor the current session.
使用 alter session 仅为当前会话设置NLS_TIMESTAMP_FORMAT或NLS_TIMESTAMP_TZ_FORMAT。
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.
我机器上安装的 Oracle 10g 的语言环境设置为中文。并且时间戳格式是中文特有的。
I need to use the US format (YYYY-MM-DD HH:MI:SS).
我需要使用美国格式 (YYYY-MM-DD HH:MI:SS)。
Any solution?
有什么解决办法吗?
回答by Ollie
From the Oracle documentation:
从 Oracle 文档:
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.
您可以通过在初始化参数文件中设置来指定 NLS_TIMESTAMP_FORMAT 的值。您可以为客户端指定它的值作为客户端环境变量。
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 的值。要在会话期间更改值,请使用 ALTER SESSION SET 语句。
NLS_TIMESTAMP_FORMAT http://download.oracle.com/docs/cd/B19306_01/server.102/b14237/initparams132.htm
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
对于 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.
您需要更改实例的参数并退回数据库。
回答by Clark
Doh. I had two tabs open and put this in the wrong thread...
多。我打开了两个标签并将其放在错误的线程中...
To set the default permanently in the database, from the database:
要在数据库中永久设置默认值,请从数据库:
alter system ... scope=spfile;
then as SYS (so you may need to talk to a DBA), and obviously at an appropriate time! -
然后作为 SYS(因此您可能需要与 DBA 交谈),并且显然是在适当的时候!——
shutdown;
startup;
(I know the spfile has been mentioned, but it can all be done from the sqlplus cmdline, at least in version 11g.)
(我知道已经提到了 spfile,但它都可以从 sqlplus cmdline 中完成,至少在版本 11g 中是这样。)