For database re-architecture I need to get DDL of each table and view in the database(Oracle). I don't want to go to property of each table/view and get SQL out of it in SQL Developer.
I successfully got DDL for table using-
select dbms_metadata.get_ddl('TABLE','Table_name','Schema_Name')
from dual;
But facing problem with VIEW and MVIEW. Could anyone provide commands/keywords for elements other than table.
Also, I want to export the result in an excel file with first column as TableName
and second column as DDL.
Double-click the view node to open its Object View tab, Select the DDL sub tab.
When you model a table in your relational model using Oracle SQL Developer Data Modeler, you are probably very curious as to the code that is being generated to represent that object. You can right-mouse-click on an object and choose 'DDL Preview,' or you can use the keyboard shortcut, Alt+Shift+I.
You can get any package's get ddl ( create script ) as follows. SQL> SELECT DBMS_METADATA. GET_DDL('PACKAGE','OBJECT_NAME','SCHEMA_NAME') FROM DUAL; You can get any package's body get ddl ( create script ) as follows.
Try the below query for view:
select text from ALL_VIEWS where upper(view_name) like upper(<view_name>);
For mviews:
select query from ALL_MVIEWS where upper(mview_name) like upper(<mview_name>);
For materialized views use:
select dbms_metadata.get_ddl('MATERIALIZED_VIEW','MView_name','Schema_Name')
from dual;
See all supported object types here: DBMS_METADATA: Object Types
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With