Oracle SQL Developer is able to export DDL through Tools -> Database Export... This works very well, but requires manual intervention.
I know of DBMS_METADATA.get_ddl()
, what I want to do is save the generated DDL in client machine which I use to connect to the Oracle DB using Oracle SQL Developer, this can be done manually.
But, I am looking for an automatic/scriptable way to export (save to local machine) DDL identical to what is exported through the manual way.
This is the SQL command I used to get DDL.
select dbms_metadata.get_ddl('obJType','ObjName','Schema') from dual;
How can I do that?
You can use spool and dbms_output.put_line to spool the results to your local machine.
You can see the link for an example utl-file-saving-in-local-machine spooling and tweak the same as per your requirement.