To back up the entire database, I recommend using the expdp / impdp command from the command line. If you need only objects, not data, you can use the METADATA_ONLY setting, see
http://download.oracle.com/docs/cd/B19306_01/server.102/b14215/dp_export.htm
If you really need to create an SQL script for your complete database and don’t want to use a commercial tool like PL / SQL Developer, TOAD, etc., you probably have to do it yourself - for example, iterate over all objects and extract their DDL script using dbms_metadata.get_ddl (), something like
foreach user u in all_users
foreach object o in users_u_objects
script += dbms_metadata.get_ddl(u, o)
Frank schmitt
source share