Oracle schema-level data migration

Source: Internet
Author: User

Recently, I joined two project teams, FALABELLA and FM, to support Oracle DB. Because the project is in the development stage, there are always some database replication work. I compared several methods, it seems that the use of EXPDP/IMPDP is not bad, it can smoothly meet the needs of developers.

Requirement: migrate data at the user/schema level.
Version: Oracle Enterprise 11g R2

In general, there are several steps:

1. view the DUMP directory of the original and target databases.
  1. SQL>Select*FromDba_directories;
  2. Sys subdir/opt/oracle/app/oracle/product/11.2.0/dbhome_1/demo/Schema/Order_entry/2002/Sep
  3. SYS SS_OE_XMLDIR/opt/oracle/app/oracle/product/11.2.0/dbhome_1/demo/Schema/Order_entry/
  4. SYS LOG_FILE_DIR/opt/oracle/app/oracle/product/11.2.0/dbhome_1/demo/Schema/Log/
  5. SYS DATA_FILE_DIR/opt/oracle/app/oracle/product/11.2.0/dbhome_1/demo/Schema/Sales_history/
  6. Sys xmldir/ade/B/2125410156/oracle/rdbms/xml
  7. SYS MEDIA_DIR/opt/oracle/app/oracle/product/11.2.0/dbhome_1/demo/Schema/Product_media/
  8. SYS DATA_PUMP_DIR/opt/oracle/app/oracle/admin/oracle/dpdump/
  9. SYS ORACLE_OCM_CONFIG_DIR/opt/oracle/app/oracle/product/11.2.0/dbhome_1/Cr/state
  10. 8RowsSelected.

AboveDATA_PUMP_DIRIt is the DUMP directory that can be used directly. The exported and imported files are placed in the above path. If not, you need to manually create and grant read/write permissions.

  1. SQL> CONN sys/AsSysdba
  2. SQL>CREATEDIRECTORY DATA_PUMP_DIRAS '/Opt/oracle/app/oracle/admin/oracle/dpdump /';
  3. SQL>GRANT READ, WRITEONDIRECTORYTOTEST;
2. Compare the username and tablespace of the original and target Databases

If the target database does not contain the username and tablespace to be imported, create username and tablespace in the target database.

  1. SQL>SelectUsername, default_tablespaceFromDba_users;-- View the users in the original database and the corresponding default tablespace
  2. SQL>CreateTablespace test_tbs datafile'/Opt/oracle/oradata/test/test_tbs01.dbf' Size1024 m autoextendOn;
  3. SQL>Create UserTest identifiedByTestDefaultTablespace test_tbs;
3. Export the script
  1. Expdp system/oracle @ orcl DIRECTORY = DATA_PUMP_DIR DUMPFILE = FALABELLA_20111014.DMP SCHEMAS = FALABELLA_CL_CATA, FALABELLA_CL_CATB, export logfile = export status = 10 parallel = 4 CONTENT =ALL
4. Import script
  1. -- Import data from one schema to another schema
  2. Impdp system/oracle @ test directory = dump_dir DUMPFILE = ATG_12OCT11.dmp LOGFILE = export SCHEMAS = QA2_ATGPUB_MF, export REMAP_SCHEMA = QA2_ATGPUB_MF: QA2_ATGPUB_MF, export: Export CONTENT =ALLPARALLEL = 4 STATUS = 10 TABLE_EXISTS_ACTION =REPLACE
  3. -- Schema does not need to be renamed.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.