How best can I recreate an Oracle database?

前端 未结 3 1613
执念已碎
执念已碎 2021-01-21 02:09

Oracle 11gR2 (x86 Windows):

I have a db with 250 tables with indexes and constraints. I need to re-create these tables, indexes and constraints in a new db and load the

3条回答
  •  一生所求
    2021-01-21 02:46

    Starting from Oracle 10g, you could use the Data Pump command-line clients expdb and impdb to export/import data and/or schema from one DB to an other. As a matter of fact, those two command-line utilities are only wrappers that "use the procedures provided in the DBMS_DATAPUMP PL/SQL package to execute export and import commands, using the parameters entered at the command line." (quoted from Oracle's documentation)

    Given your needs, you will have to create a directory then generate a full dump of your database using expdb:

    SQL> CREATE OR REPLACE DIRECTORY dump_dir AS '/path/to/dump/folder/';
    
    sh$ expdp system@db10g full=Y directory=DUMP_DIR dumpfile=db.dmp logfile=db.log
    

    As the dump is written using some binary format, you will have to use the corresponding import utility to (re)import your DB. Basically replacing expdb by impdb in the above command:

    sh$ impdp system@db10g full=Y directory=DUMP_DIR dumpfile=db.dmp logfile=db.log
    

    For simple table dump, use that version instead:

    sh$ expdp sylvain@db10g tables=DEPT,EMP directory=DUMP_DIR dumpfile=db.dmp logfile=db.log
    

    As you noticed, you can use it with your standard user account, provided you have access to the given directory (GRANT READ, WRITE ON DIRECTORY dump_dir TO sylvain;).


    For detailed usage explanations, see

    • http://www.oracle-base.com/articles/10g/oracle-data-pump-10g.php.

提交回复
热议问题