详解Oracle数据库如何通过DBMS_METADATA包来获取对象DDL语句
概述
虽然我们用PLSQL可以看到数据库对象的DDL语句,但如果想要用sql来实现呢?下面先讲下DBMS_METADATA的作用。
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:
- GET_XML
- GET_DDL
- GET_SXML
- GET_DEPENDENT_XML
- GET_DEPENDENT_DDL
- GET_GRANTED_XML
- GET_GRANTED_DDL
获得表、索引、视图、存储过程、函数的DDL
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方面的内容,感兴趣的朋友可以关注一下~
相关推荐
云中舞步 2020-11-12
thunderstorm 2020-08-19
拼命工作好好玩 2020-08-03
好记忆也需烂 2020-07-28
zyjj 2020-06-21
CharlesYooSky 2020-06-11
lmseohy 2020-04-22
boredbird 2020-02-02
vivenwan 2020-02-01
heniancheng 2020-01-23
tlsmile 2020-01-13
云之飞踢 2019-12-16
点滴技术生活 2019-12-02
sofast 2019-11-19
yongyoumengxiang 2019-09-06
大伟爱自由 2014-05-29
javashixisheng 2019-07-01
muzirigel 2019-07-01
打卤 2013-04-11