Generating DDL script for object without schema name baked in using DBMS_METADATA.GET_DDL?

喜欢而已 提交于 2019-12-05 03:32:06

Use SET_REMAP_PARAM with the REMAP_SCHEMA option:

DBMS_METADATA.SET_REMAP_PARAM(th,'REMAP_SCHEMA','HR',NULL);

This will map the HR schema to NULL (you'll need a job handle, though); for a full example, see metadata_api documentation

I recently stumbled upon the following which allows you to get ddl without the schema name.

It looks a lot simpler than any other way I have seen so far although its not included in any Oracle documentation. I spotted it in the Statements Log in SQL Developer, which generates ddl without the schema name.

DBMS_METADATA.SET_TRANSFORM_PARAM(dbms_metadata.SESSION_TRANSFORM, 'EMIT_SCHEMA', false);

You don't need to get handles or anything nasty just EXEC the above before calling DBMS_METADATA.GET_DDL

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!