ORA-00942: 表或视图不存在:如何找到它正在谈论哪个表或视图

发布于 2024-07-06 06:57:39 字数 518 浏览 4 评论 0原文

我们正在测试中运行一个 java/hibernate 应用程序来对抗 ORACLE 10g。 有时,我们会看到这个错误:

ORA-00942: 表或视图不存在

有没有办法找出 ORACLE 正在谈论的表/视图?

我知道我可以在 hibernate 中添加额外的日志级别,这将显示它在 ORACLE 上执行的所有 SQL,然后运行该 SQL 来找出哪个 TABLE/VIEW 丢失或缺少权限。 但考虑到它处于测试/暂存阶段,这会降低性能。

有没有一种简单的方法来缩小表/视图名称的范围?

更新:

正如您所知,我无法控制 Oracle DB 服务器环境。
我启用了 Hibernate 跟踪/日志记录并发现了有效的 SQL。 我什至使用 Wireshark(这是一个 TCP 数据包过滤器)来查看 hibernate 实际发送的内容,这是一个有效的 SQL。 那么,为什么 Oracle 会偶尔而不是总是抱怨它呢?

We're running a java/hibernate app going against ORACLE 10g in TESTING. Once in a while, we're seeing this error:

ORA-00942: table or view does not exist

Is there a way to find out which table/view(s) ORACLE is talking about ?

I know that I can add extra levels of logging in hibernate which will show all the SQL that it executes on ORACLE and then run that SQL to figure out which TABLE/VIEW is missing or missing permission. But given that it is in TESTING/STAGING, that will slow down performance.

Is there a simple way to narrow down on the Table/View Name ?

UPDATE :

Just so you know, I don't have control over the Oracle DB Server Environment.
I enabled Hibernate tracing/logging and found a VALID SQL. I even put Wireshark(which is a TCP packet filter) to see what hibernate actually sends and that was a valid SQL. So, why would Oracle complain about it once in a while and NOT always.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

枕梦 2024-07-13 06:57:39

这就是我所做的,向最初来自于此的人致歉,我知道我从某个网站上获取了它,但现在不记得在哪里了。

在预生产中,我有这个

create table caught_errors (
  dt        date,               
  username  varchar2( 30), -- value from ora_login_user
  msg       varchar2(2000),
  stmt      varchar2(2000)
);


create or replace trigger catch_errors
   after servererror on database
declare
   sql_text ora_name_list_t;
   msg_     varchar2(2000) := null;
   stmt_    varchar2(2000) := null;
begin

  for depth in 1 .. ora_server_error_depth loop
    msg_ := msg_ || ora_server_error_msg(depth);
  end loop;

  for i in 1 .. ora_sql_txt(sql_text) loop
     stmt_ := stmt_ || sql_text(i);
  end loop;

  insert into 
    caught_errors (dt     , username      ,msg ,stmt )
           values (sysdate, ora_login_user,msg_,stmt_);
end;
/

任何时候抛出服务器错误,它被捕获并记录到表中,然后我可以检查该表以查找有问题的查询,并根据需要退款以查看丢失的表(当您在 sqlplus 中运行查询时) ,它会告诉你表格)

注意,是的,这有问题,例如,如果 catch_errors 被删除,或者本身引发错误,你可能会得到递归循环,因此为什么这只存在于预生产中。

This is what I do, appologies to whoever this originally came from, I know I took it from some website, but can't remember where right now.

In preproduction, I have this

create table caught_errors (
  dt        date,               
  username  varchar2( 30), -- value from ora_login_user
  msg       varchar2(2000),
  stmt      varchar2(2000)
);


create or replace trigger catch_errors
   after servererror on database
declare
   sql_text ora_name_list_t;
   msg_     varchar2(2000) := null;
   stmt_    varchar2(2000) := null;
begin

  for depth in 1 .. ora_server_error_depth loop
    msg_ := msg_ || ora_server_error_msg(depth);
  end loop;

  for i in 1 .. ora_sql_txt(sql_text) loop
     stmt_ := stmt_ || sql_text(i);
  end loop;

  insert into 
    caught_errors (dt     , username      ,msg ,stmt )
           values (sysdate, ora_login_user,msg_,stmt_);
end;
/

Any time servererror is thrown, its caught and logged to a table, I can then check that table to find the offending queries, and refund them as needed to see the missing table (when you run the query in sqlplus, it will tell you the table)

Note, yes, there is issues with this, eg, what if caught_errors is dropped, or raises an error itself, you could get recursive loop, hence why this only exists in preproduction.

茶底世界 2024-07-13 06:57:39

当 Oracle 审计打开时,查看 DBA_AUDIT_EXISTS 表。 我相信 Oracle 可以提供非常详细的审计,您可以根据需要通过 DB 命令简单地打开和关闭审计,尽管我不记得它们是什么。

看:
http://docs.oracle.com/cd/B19306_01/ network.102/b14266/cfgaudit.htm

一些想法(我刚刚快速用谷歌搜索)

Take a look into the DBA_AUDIT_EXISTS table, when auditing is turned on for Oracle. I believe that Oracle can provide very detailed auditing which you can simply toggle on and off when you like via DB commands, although I dont remember what they are off the top of my head.

See:
http://docs.oracle.com/cd/B19306_01/network.102/b14266/cfgaudit.htm

for some idea (which I just quickly googled for)

回忆那么伤 2024-07-13 06:57:39

您应该检查该帐户是否有访问目标表的权限。

You should check the account, which whether has the permit to access the target table.

你如我软肋 2024-07-13 06:57:39

我不认为这里有灵丹妙药。
可能是查询中缺少表或拼写错误的表名。
这可能是一个特权问题。 如果不执行查询,您就无法真正判断,

我建议您继续以可以打开和关闭它的方式来检测您的代码。 运行它,提取查询,然后将其发送给 DBA 进行解决。

I don't think there is a magic bullet here.
It may be a missing table, or a misspelled table name in the query.
It may be a privilege issue. You can't really tell without executing the query

I suggest you go ahead and instrument your code in such a way that you can turn it on and off. Run it, extract the query, and ship it off to your DBA to resolve.

过去的过去 2024-07-13 06:57:39

如果您在导入数据库时​​遇到此问题,请检查表空间名称是否正确。

Please check of the tablespace name is correct if you are facing this issue while importing DB.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文