oracle 什么是查看 VIEW 语句的 SQLPlus 命令?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12679923/
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
what is SQLPlus command to view a VIEW statement?
提问by Mowgli
I just found out that one of the queries I am running is not coming from actual table, it is coming from a VIEW.
我刚刚发现我正在运行的查询之一不是来自实际表,而是来自 VIEW。
I would like to see the SQL query in that VIEW. If I try to describe
I get an object does not exist error. When I SELECT from the view I get some data.
我想在该视图中查看 SQL 查询。如果我尝试describe
我得到一个对象不存在错误。当我从视图中选择时,我得到了一些数据。
回答by Wolf
To see the SQL underlying a view, you'll need to query the data dictionary. Try
要查看视图背后的 SQL,您需要查询数据字典。尝试
select view_name, text from user_views where view_name = 'MY_VIEW';
If your user does not own the view, then try all_views
;
如果您的用户不拥有该视图,请尝试all_views
;
回答by Ben
If you would like to see the actual SQL used to create the view you can use the function dbms_metadata.get_ddl
, which returns a clob:
如果您想查看用于创建视图的实际 SQL,您可以使用dbms_metadata.get_ddl
返回一个 clob的函数:
select dbms_metadata.get_ddl ( 'VIEW'
, 'MY_VIEW' -- view name
)
from dual
There are a few more options if you need them.
如果您需要,还有更多选择。
If you want to just describeit as usual. If this is not working you're in the wrong schema or the object does not exist:
如果你想像往常一样描述它。如果这不起作用,则您处于错误的架构中或对象不存在:
DESC MY_VIEW
If you're in the incorrect schema you can use:
如果您处于不正确的架构中,您可以使用:
select dbms_metadata.get_ddl ( 'VIEW'
, 'MY_VIEW', -- view name
, 'MY_SCHEMA'
)
from dual
or
或者
DESC MY_SCHEMA.MY_VIEW
回答by AnBisw
Or better yet, Click on the view in the left connections pane in SQLDeveloper. Once the view opens click on the SQL Tab to see the underlying SQL on it. To find which user/schema the view is in use
或者更好的是,单击 SQLDeveloper 左侧连接窗格中的视图。视图打开后,单击 SQL 选项卡以查看其上的底层 SQL。查找视图正在使用的用户/模式
select owner
from all_objects
where object_name='VIEW_NAME' and object_type='VIEW';