为 Oracle 存储过程依赖图生成 DDL
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26660758/
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
Generate DDL for Oracle Stored Procedure Dependency Graph
提问by orangepips
With TOAD I know I can view the dependency (uses) graph of a stored procedure using the schema browser. And, the Oracle utility procedure deptree_fill
can do something similar. What I want to do is script out all of the stored procedures, functions and table definition DLLs into a file that I can use to recreate those objects in another database. Is there a tool or an existing script for this purpose? My own searching has not found a solution. In my particular case the stored procedure uses a dozen other procedures, a few functions and twenty tables.
使用 TOAD,我知道我可以使用模式浏览器查看存储过程的依赖关系(使用)图。而且,Oracle 实用程序deptree_fill
可以做类似的事情。我想要做的是将所有存储过程、函数和表定义 DLL 脚本化到一个文件中,我可以使用该文件在另一个数据库中重新创建这些对象。是否有用于此目的的工具或现有脚本?我自己的搜索没有找到解决方案。在我的特殊情况下,存储过程使用了十几个其他过程、几个函数和二十个表。
Edit 1
编辑 1
Maybe my original question was not clear. What I am looking for is something that will take the stored procedure I am interested in and script it and all of its dependency graph into one or more files.
也许我最初的问题不清楚。我正在寻找的是一种能够将我感兴趣的存储过程和它及其所有依赖关系图脚本化到一个或多个文件中的东西。
The schema I am dealing with has hundreds of objects in it and the dependency graph has ~50 objects in it. So I'd rather not dig through large lists in TOAD or write an Oracle script myself if I can avoid it.
我正在处理的模式中有数百个对象,依赖关系图中有大约 50 个对象。因此,如果可以避免的话,我宁愿不在 TOAD 中挖掘大型列表或自己编写 Oracle 脚本。
回答by Dmitriy
Hmm, it is quite easy to find in google. Get table DDL: How to get Oracle create table statement in SQL*Plus
嗯,在谷歌上很容易找到。获取表 DDL:如何在 SQL*Plus 中获取 Oracle 创建表语句
Code of stored procedures can be found in table USER_SOURCE
.
存储过程代码见表USER_SOURCE
。
Also, for exporting schema to another DB you can use oracle utilities: http://docs.oracle.com/cd/B28359_01/server.111/b28319/exp_imp.htm#g1070082
此外,要将架构导出到另一个数据库,您可以使用 oracle 实用程序:http: //docs.oracle.com/cd/B28359_01/server.111/b28319/exp_imp.htm#g1070082
回答by a_horse_with_no_name
All sources can be extracted using the dbms_metadata
package.
可以使用该dbms_metadata
包提取所有源。
To get the source of a table:
要获取表的源:
select dbms_metadata.get_ddl('TABLE', 'SOME_TABLE')
from dual;
To get the source of a stored procedure:
获取存储过程的源代码:
select dbms_metadata.get_ddl('PROCEDURE', 'SOME_PROC')
from dual;
Using that you can create a SQL script that extracts everything and then spool the result to a file.
使用它,您可以创建一个 SQL 脚本来提取所有内容,然后将结果假脱机到一个文件中。
More details about the various functions in dbms_metadata
can be found in the manual:
有关各种功能的更多详细信息dbms_metadata
可以在手册中找到:
http://docs.oracle.com/cd/E11882_01/appdev.112/e25788/d_metada.htm#i1015856
http://docs.oracle.com/cd/E11882_01/appdev.112/e25788/d_metada.htm#i1015856
回答by Michael S.
In Toad see the Generate Schema Script window. You can get to it from the Database|Export menu. There are many options there to include/exclude what you want.
在 Toad 中,查看生成架构脚本窗口。您可以从数据库|导出菜单访问它。有很多选项可以包含/排除您想要的内容。