SQL 如何在Oracle 中打印出一个过程的定义?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7167307/
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
how to print out the definition of a procedure in Oracle?
提问by Nicholas
Is there a way in oracle to see what a procedure's structure is? I'm trying to log and am running procedures and wanted to store the actual procedure structure in my log.
oracle中有没有办法查看过程的结构是什么?我正在尝试记录并正在运行过程,并希望将实际过程结构存储在我的日志中。
回答by Justin Cave
You could query the ALL_SOURCE
table
你可以查询ALL_SOURCE
表
SELECT text
FROM all_source
WHERE owner = <<owner of procedure>>
AND name = <<name of procedure>>
ORDER BY line
If you are dealing with a procedure that is inside a package
如果您正在处理包内的程序
SELECT text
FROM all_source
WHERE owner = <<owner of procedure>>
AND name = <<name of procedure>>
AND type = 'PACKAGE BODY'
ORDER BY line
will give you the text of the package body. You could also get the text of the package specification using a TYPE
of "PACKAGE"
会给你包体的文本。您还可以使用TYPE
“PACKAGE”来获取包规范的文本
回答by cwallenpoole
SELECT TEXT, LINE FROM ALL_SOURCE WHERE
NAME = UPPER('$name') -- the table also has an owner field to track the user
ORDER BY TYPE, -- type is generally procedure, but there are functions and
-- more complex structures as well, such as PACKAGE
TO_NUMBER( LINE )
回答by DCookie
dbms_metadata package, get_ddl function, perhaps?
dbms_metadata 包,get_ddl 函数,也许?
SELECT dbms_metadata.get_ddl('PROCEDURE','<yourproc>','<schema>') FROM dual;