如何在与oracle中的另一个模式进行比较后创建缺失函数的DDL?

时间:2016-04-15 09:29:20

标签: oracle ddl

我想从另一个数据库导入函数/过程,只导入当前数据库中不存在的函数/过程。 我用这个得到了对象名: -

select OBJECT_NAME from dba_objects where owner = 'AKHSYS'  and  object_type in ( 'PROCEDURE', 'PACKAGE', 'FUNCTION', 'PACKAGE BODY' ) minus select OBJECT_NAME from dba_objects  where owner = 'LDHSYS'  and object_type in ( 'PROCEDURE', 'PACKAGE', 'FUNCTION', 'PACKAGE BODY' );

但是如何创建当前架构中缺少的所有函数的ddl脚本?

1 个答案:

答案 0 :(得分:1)

使用DBMS_METADATA。例如:

SELECT owner, object_type, object_name, DBMS_METADATA.get_ddl (object_type, object_name, owner)
  FROM (SELECT owner, OBJECT_NAME, object_type
          FROM dba_objects
         WHERE owner = USER AND object_type IN ('PROCEDURE', 'PACKAGE', 'FUNCTION'))
ORDER BY 1,2,3