你将如何在 oracle 10g 中只进行存储过程备份?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1026378/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 18:26:01  来源:igfitidea点击:

how will you take only stored procedure backup in oracle 10g?

oraclestored-proceduresbackup

提问by Kthevar

how will you take only stored procedure backup in oracle 10g?

你将如何在 oracle 10g 中只进行存储过程备份?

回答by Colin Pickard

ammoQ's answer is correct.

ammoQ 的答案是正确的。

To take it a bit further, if you want just the stored procs without the table structure, you will need to connect to the database and use SQL (i.e. with sqlplus or something). Then, using a list of the stored procs you are interested in, call the dbms_metadata function. You can use sqlplus to do something like this:

更进一步,如果您只想要没有表结构的存储过程,您将需要连接到数据库并使用 SQL(即使用 sqlplus 或其他东西)。然后,使用您感兴趣的存储过程列表,调用 dbms_metadata 函数。您可以使用 sqlplus 执行以下操作:

SELECT dbms_metadata.get_ddl('PROCEDURE','PROC1') FROM dual;

which will give you the source of procedure PROC1.

这将为您提供过程 PROC1 的来源。

Also there is a view called USER_SOURCE, which you can use something like this:

还有一个名为 USER_SOURCE 的视图,您可以使用以下内容:

select * from user_source where type in ('PROCEDURE', 'PACKAGE', 'PACKAGE_BODY', 'FUNCTION', 'TRIGGER');

which gives you the source for everything owned by the user you are logged in as.

这为您提供了您登录的用户所拥有的所有内容的来源。

回答by Andrew not the Saint

If you're not taking care of configuration management, i.e. not keeping your stored procedures in a proper source control application (e.g. CVS, Subversion, MSS) you're simply not doing the right thing. Even a one-man team should use a version control system, for any non-trivial work.

如果您没有注意配置管理,即没有将您的存储过程保存在适当的源代码控制应用程序(例如 CVS、Subversion、MSS)中,那么您只是没有做正确的事情。对于任何重要的工作,即使是单人团队也应该使用版本控制系统。

Read up on Revision control

阅读修订控制

回答by Erich Kitzmueller

Tools like TOAD offer a feature to export the source code of stored procedures, functions, packages, triggers etc.

TOAD 等工具提供了导出存储过程、函数、包、触发器等源代码的功能。

If you don't mind exporting table structure (without content) as well,

如果您不介意导出表结构(没有内容),

exp user/password file=emptybackup.dmp owner=myschema rows=n

should do the trick.

应该做的伎俩。