database PL/SQL: ORA-00942: 表或视图不存在 V$SQL
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10101177/
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
PL/SQL: ORA-00942: table or view does not exist V$SQL
提问by Gaurav Soni
I have created a procedure and used the below statement inside that .
我创建了一个过程并在其中使用了以下语句。
select sql_id into v_sql_id from v_$sql where sql_text =v_sql;
I am getting the following error PL/SQL: ORA-00942: table or view does not exist
我收到以下错误 PL/SQL: ORA-00942: table or view does not exist
I have checked the synonym its owner is PUBLIC,so it should run in this case ,but its not working .
我已经检查了它的所有者的同义词PUBLIC,所以它应该在这种情况下运行,但它不起作用。
Another thing i can select sql_id from v_$sql where sql_text =v_sql;this in simple editor .Can anyone help me with this .
另一件事我可以select sql_id from v_$sql where sql_text =v_sql;在简单的编辑器中做到这一点。任何人都可以帮我解决这个问题。
回答by Korhan Ozturk
Database dictionary related or system tables (v_$sql in this case) are owned by Oracle sysuser and needs special privileges to access them. You need to login to oracle database as sysdba useror get those privilages (your DBA might help you with this) to get access for the data dictionary views.
数据库字典相关或系统表(在本例中为 v_$sql)由 Oraclesys用户拥有,需要特殊权限才能访问它们。您需要以身份登录 oracle 数据库sysdba user或获取这些权限(您的 DBA 可能会帮助您)才能访问数据字典视图。
As mentioned in this article
如本文所述
The problem is that procedures don't respect roles; only directly granted rights
are respected. So, that means that table_owner has to regrant the right to select
So, try the following to grant the SELECT on all dictionay view so that you can use it in your pl/sql blocks.
因此,请尝试以下操作以在所有字典视图上授予 SELECT 权限,以便您可以在 pl/sql 块中使用它。
grant select any dictionary to USERNAME
回答by a_horse_with_no_name
Most probably the user you are using was given access to the view through a role rather than the select privilege directly.
很可能您正在使用的用户通过角色而不是直接选择权限获得了对视图的访问权限。
Unfortunately privileges obtained through a role are not active when running PL/SQL.
不幸的是,在运行 PL/SQL 时,通过角色获得的权限不是活动的。
You need to ask your DBA to grant the SELECT privilege directly to your user.
您需要让您的 DBA 直接向您的用户授予 SELECT 权限。

