oracle SqlPlus 查询问题(Package Spec 和 Body)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6986544/
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
SqlPlus query issue (Package Spec and Body)
提问by Hyman
I am trying to get package spec and body from sqlplus by doing so..
我正在尝试通过这样做从 sqlplus 获取包规范和正文..
select text from all_source
where name = 'PACK_Hyman'
order by line;
but I am only getting its body not the spec.. what I have to change to get both of them as one file.. Thank you
但我只得到它的主体而不是规范..我必须改变什么才能将它们作为一个文件..谢谢
回答by Basanth Roy
There is a TYPE column in all_source view. The type can have 2 values - 'PACKAGE' and 'PACKAGE BODY'. So to get the spec,
all_source 视图中有一个 TYPE 列。类型可以有 2 个值 - 'PACKAGE' 和 'PACKAGE BODY'。所以要获得规格,
select text from all_source
where name = 'PACK_Hyman'
and type = 'PACKAGE'
order by line;
and to get the body
并得到身体
select text from all_source
where name = 'PACK_Hyman'
and type = 'PACKAGE BODY'
order by line;
Additionally, instead of using all_source, you can use user_source. all_source includes everything including system packages. USER_SOURCE only has user defined packages.
此外,您可以使用 user_source,而不是使用 all_source。all_source 包括所有内容,包括系统包。USER_SOURCE 只有用户定义的包。
回答by Codo
To get the package body, you run:
要获取包正文,请运行:
select text from all_source
where name = 'PACK_Hyman'
and type = 'PACKAGE BODY'
order by line;
As opposed to:
相对于:
select text from all_source
where name = 'PACK_Hyman'
and type = 'PACKAGE'
order by line;
But chances are you don't have the right to see the package body. So it's hidden from the ALL_SOURCE table.
但您可能无权查看包裹正文。所以它在 ALL_SOURCE 表中是隐藏的。