Oracle PL/SQL developer中查看带日期的时间部分的设置是什么?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23701995/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 02:21:41  来源:igfitidea点击:

What is the setting to view the time part with date in Oracle PL/SQL developer?

oracleoracle-sqldeveloper

提问by Mistu4u

I have a table named AUDIT which saves all the modifications done on an account. There is a field AUDIT_DATE which contains the date on which a particular modification has been done. Now the problem is, in one of my colleagues Oracle PL/SQL developer, I can see the time as well as the date in the AUDIT_DATE column, but in my Oracle PL/SQL developer, I can't see the time part. So I believe some setting is not properly done in my Oracle PL/SQL developer and that's why I can't see the time part. I asked the colleague, but he has no clue about the discrepancy.

我有一个名为 AUDIT 的表,它保存对一个帐户所做的所有修改。AUDIT_DATE 字段包含完成特定修改的日期。现在的问题是,在我的一位同事 Oracle PL/SQL 开发人员中,我可以在 AUDIT_DATE 列中看到时间和日期,但是在我的 Oracle PL/SQL 开发人员中,我看不到时间部分。所以我相信我的 Oracle PL/SQL 开发人员没有正确完成某些设置,这就是为什么我看不到时间部分。我问过同事,但他对这种差异一无所知。

回答by Alex Poole

If you want to see dates with times shown as well without applying a format mask with to_char(), you need to change your NLS_DATE_FORMAT. Assuming you do mean Oracle SQL Developer, you can do this from Tools->Preferences, expand the Database section in the panel on the left, and select NLS:

如果您想查看显示时间的日期而不应用带有 的格式掩码to_char(),则需要更改NLS_DATE_FORMAT. 假设您的意思是 Oracle SQL Developer,您可以从 Tools->Preferences 执行此操作,展开左侧面板中的 Database 部分,然后选择 NLS:

enter image description here

在此处输入图片说明

At the moment NLS_DATE_FORMATis set to DD-MON-RR, which would show today as 16-MAY-14. To show the full date and time I might set it to YYYY-MM-DD HH24:MI:SS. You might want to change the NLS_TIMESTAMPformat as well.

目前NLS_DATE_FORMAT设置为DD-MON-RR,今天将显示为16-MAY-14。要显示完整的日期和时间,我可能会将其设置为YYYY-MM-DD HH24:MI:SS. 您可能还想更改NLS_TIMESTAMP格式。

PL/SQL Developer also has NLS options under Tools->Preferences:

PL/SQL Developer 在 Tools->Preferences 下也有 NLS 选项:

enter image description here

在此处输入图片说明

You can see the available format models in the documentation.

您可以在文档中查看可用的格式模型

If you're writing code that will or may ever be executed by someone else, do not rely on implicit formatting using those parameters. They're fine for ad hoc queries in your own enclosed environment, but they may break in interesting ways when someone else - with different NLS settings - runs them. For anything except ad hoc queries you should really specify the mask, using to_char(<column>, 'YYYY-MM-DD HH24:MI:SS')or whatever model is appropriate. This of course also means you get the right formatting for the column; if you have columns that only represent times then setting the session's format model and relying on that means you see all the 00:00:00times, which is often just noise.

如果您正在编写将要或可能会被其他人执行的代码,请不要依赖使用这些参数的隐式格式设置。它们适用于您自己封闭环境中的即席查询,但是当其他人(具有不同的 NLS 设置)运行它们时,它们可能会以有趣的方式中断。对于临时查询以外的任何内容,您应该真正指定掩码、使用to_char(<column>, 'YYYY-MM-DD HH24:MI:SS')或任何合适的模型。这当然也意味着您可以获得正确的列格式;如果您有仅代表时间的列,则设置会话的格式模型并依赖它意味着您可以看到所有00:00:00时间,这通常只是噪音。