hzcyhujw 2019-07-08
虽然我们用PLSQL可以看到数据库对象的DDL语句,但如果想要用sql来实现呢?下面先讲下DBMS_METADATA的作用。
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.
GET_xxx Functions
The following GET_xxx functions let you fetch metadata for objects with a single call:
select dbms_metadata.get_ddl('TABLE','TABLE_NAME','TABLE_OWNER') from dual;
select dbms_metadata.get_ddl('INDEX','INDEX_NAME','INDEX_OWNER') from dual;
select dbms_metadata.get_ddl('VIEW','VIEW_NAME','VIEW_OWNER') from dual;
select dbms_metadata.get_ddl('PROCEDURE','PROCEDURE_NAME','PROCEDURE_OWNER') from dual;
select dbms_metadata.get_ddl('FUNCTION','FUNCTION_NAME','FUNCTION_OWNER') from dual;
后面会分享更多devops和DBA方面的内容,感兴趣的朋友可以关注一下~