Export SQL statements from Oracle 11g database via command line

exportoracle

I'd like to export an Oracle 11g database as a series of SQL statements via the command line. I'd like the functionality of SQL Developer (the process described here https://dba.stackexchange.com/a/10071/7660) but via the command line.

Note that the data must be in a flat file and not a binary format (as with imp/exp or impdp/expdb (Datapump)).

Is this possible? If so, how?

Best Answer

Depends what you mean by 'from the command line', but you can generate the DDL via the dbms_metadata package (see here for example).

If you want the data as well then you'd then have to roll your own, unless you find a generic script somewhere on the web. Automating the script with dynamic SQL and the data disctionary is certainly possible - it's what SQL*Developer must do ultimtately - it will just need some work to get right, and to handle things like embedded quotes. No quick fix I'm afraid.