提取数据库对象的代码或脚本 [英] Extract code or script of database objects

查看:162
本文介绍了提取数据库对象的代码或脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从所有的函数,过程,包,视图和表中提取代码(脚本),这样当我移动到生产时,我可以运行脚本来创建所有的对象。

I need to extract code(script) from all my functions, procedures, packages, views and tables, so that when I move to production I could run the script to create all the objects.

在开发时,我没有对所有数据库对象进行脚本备份。

While developing I did not take script backup of all database objects.

提取代码或脚本的最好方法是什么?

What is the best way to extract code or script? Any suggestion or help is highly appreciable.

感谢

推荐答案

做使用版本控制系统不是吗?请执行。

You do use a version control system don't you? Please do.

无法使用系统函数 dbms_metadata.get_ddl ,它将返回用于创建对象的DDL的clob。这需要对每个单独的对象执行,因此可能需要通过 user_objects

Failing that you can use the system function dbms_metadata.get_ddl, which will return a clob of the DDL used to create the object. This will need to be done for each individual object so it might be worth looping through user_objects.

或者,您可以通过右键单击PL / SQL Developer中的定义一个对象并使用 view 选项,然后在右下角可以查看用于创建对象的SQL。

Alternatively you can go through the definitions in PL/SQL Developer by right-clicking on an object and using the view option then in the bottom right corner you can view the SQL used to create the object.

还有一个导出工具,没有对如何使用它作为SQL Developer变体的很好的解释。

There is also an export "tool", which doesn't have as good an explanation of how to use it as the SQL Developer variant.

当然,正确的答案是获得版本控制系统并使用它。

Of course, the correct answer is get a version control system and use it.

这篇关于提取数据库对象的代码或脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆