The DBMS_METADATA package provides a way for you to retrieve metadata from the database dictionary as XML or creation DDL and to submit the XML to re-create the object.
TableSpace
select dbms_metadata.get_ddl(‘TABLESPACE’,tablespace_name) from dba_tablespaces;
Get All Tablespace Script :
set head off echo off
select ‘select dbms_metadata.get_ddl(”TABLESPACE”,”’
|| tablespace_name || ”’) from dual;’ from dba_tablespaces
Table
select dbms_metadata.get_ddl(‘TABLE’,’DEPT’,’SCOTT’) from dual;
User
SELECT dbms_metadata.get_ddl(‘USER’,’SCOTT’) FROM dual;
Role
SELECT DBMS_METADATA.GET_GRANTED_DDL(‘ROLE_GRANT’,’SCOTT’) from dual;
SELECT DBMS_METADATA.GET_GRANTED_DDL(‘OBJECT_GRANT’,’SCOTT’) from dual;
SELECT DBMS_METADATA.GET_GRANTED_DDL(‘SYSTEM_GRANT’,’SCOTT’) from dual;
SELECT dbms_metadata.get_ddl(‘ROLE’,’RESOURCE’) from dual;
This is the Most common Usage for this package more information read Oracle Documentation
Thank you
Osama mustafa
Like this:
Like Loading...
Related
Published by Osama Mustafa
Osama considered as one of the leaders in Cloud technology, DevOps and database in the Middle-East. I have more than ten years of experience within the industry. moreover, certfied 4x AWS , 4x Azure and 6x OCI, have also obtained database certifications for multiple providers.
In addition to having experience with Oracle database and Oracle products, such as middle-ware, OID, OAM and OIM, I have gained substantial knowledge with different databases.
Currently, I am architecting and implementing Cloud and DevOps. On top of that, I'm providing solutions for companies that allow them to implement the solutions and to follow the best practices.
View all posts by Osama Mustafa