Oracle imports DMP data, with different tablespaces

Source: Internet
Author: User

1. Use IMP to export data

Run cmd to enter the orcle installation directory bin and enter the following command:

Exp username/password @ oracleepp file = c: \ hysjb. dmp owner = magazine_hy rows = y

2. Use IMP to generate the index. SQL File

ImP <xe_username>/<password> @ Xe file = <FILENAME. DMP> indexfile = index. SQL full = y

3. Modify the index. SQL File

Find: 'rem <space> 'Replace: <nothing>

Find: '"<source_tablespace>" 'replace:' "users "'

Find: '...' Replace: 'rem ...'

Find: 'connect 'replace: 'rem connect'

PS: query the table space statement:

Select

DF . Tablespace_name "Tablespace_name" , Totalspace "Totalspace/M" , Freespace "Freespace/M" , Round (( 1 - Freespace / Totalspace )* 100 , 2 ) "Used %"

From

( Select Tablespace_name , Round ( Sum ( Bytes )/ 1024 / 1024 ) Totalspace From Dba_data_files Group By Tablespace_name ) DF ,

( Select Tablespace_name , Round ( Sum ( Bytes )/ 1024 / 1024 ) Freespace From Dba_free_space Group By Tablespace_name ) FS

Where DF . Tablespace_name = FS . Tablespace_name ;

4. Use sqlplus to run this SQL statement to generate the table structure

Sqlplus <xe_username>/<password> @ Xe @ index. SQL

5. Enter the database diasble to drop dependencies.

Select 'AlterTable' | Table_name | 'Disable constraint' | Constraint_name | ';' From User_constraints

Where Constraint_type='R ';

Export the CSV file as imp. SQL, delete the "number, and execute.

6. import data. Run the following command in cmd:

ImP <xe_username>/<password> @ Xe file = <FILENAME. DMP> fromuser = <original_username> touser = <xe_username> ignore = y

7. Replace disable in IMP. SQL with enable for execution. Enable dependency

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.