Oracle 正常运行时间查询

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

Oracle Uptime Query

oracle

提问by Greg Reynolds

Is there a way for a non admin user to check the uptime of an Oracle instance? I.e. I don't have sysdba privileges.

非管理员用户有没有办法检查 Oracle 实例的正常运行时间?即我没有 sysdba 权限。

采纳答案by APC

Your question specifies "non admin user" so I'm afraid the answer is probably no. The usual mechanisms require selecting from V$ views - V$INSTANCE or V$SESSION. Neither of these are granted to PUBLIC by default.

您的问题指定为“非管理员用户”,因此恐怕答案是否定的。通常的机制需要从 V$ 视图中进行选择 - V$INSTANCE 或 V$SESSION。默认情况下,这些都不会授予 PUBLIC。

If you ask your DBA nicely they might be prepared to grant you access to those views, or at least write a wrapping function (or functions) to expose those values.

如果您很好地询问您的 DBA,他们可能准备授予您访问这些视图的权限,或者至少编写一个包装函数(或多个函数)来公开这些值。

回答by Simeon

Try this. It doesn't require an admin user, although SELECTaccess to the v_$instancetable.

尝试这个。尽管SELECT可以访问该v_$instance表,但它不需要管理员用户。

SELECT to_char(startup_time,'DD-MON-YYYY HH24:MI:SS') "DB Startup Time"
FROM sys.v_$instance;

Or, if you assume that PMON startup time is the same as the database startup time, you can get the uptime like this:

或者,如果假设 PMON 启动时间与数据库启动时间相同,则可以像这样获得正常运行时间:

SELECT to_char(logon_time,'DD/MM/YYYY HH24:MI:SS')
FROM v$session
WHERE sid=1;

回答by Dmitry.M

The PMON's sid is not always equal to 1. So it is better to use the query:

PMON 的 sid 并不总是等于 1。所以最好使用查询:

SELECT t.LOGON_TIME FROM v$session t where upper(t.PROGRAM) like ('%PMON%')

it works for 11.2.0.4 and 12.1.0.2 on solaris and linux redhat.

它适用于 11.2.0.4 和 12.1.0.2 在 solaris 和 linux redhat 上。

回答by p.marino

I'd suggest something like this- but you should give more details, for example what OS you are on, and what version of Oracle.

我建议像这样-但你应该提供更多的细节,比如你是什么操作系统和Oracle的什么版本。