Detailed description of Oracle cross-platform migration structure without data migration

Source: Internet
Author: User

This article describes Oracle cross-platform migration, such as migrating data from Oracle to other types of databases, but retaining the original structure. This reduces the workload of DBAs. I hope this article will help you better understand Oracle cross-platform migration.

1. Export related information in the original database:

 
 
  1. expdp system/sywg1234 directory=test dumpfile=test.dump logfile=test.log   
  2. schemas=SYWG,GAZX,WEBCALL,HQ,SJCK,SJPZ CONTENT=METADATA_ONLY 

2. tablespace information of the original database:

Export the tablespace information in TOAD, edit the export script, and delete the system information. Change the Directory and file size as needed.

3. perform operations in the target database:

Copy the dump file exported from the original database to a directory in the target database;

Create an import directory;

 
 
  1. impdp system/sywg1234 directory=test dumpfile=test.dump logfile=test_imp.log   
  2. CONTENT=METADATA_ONLY exclude=statistc 

Note:

There is a big problem at this time, that is, even if the table structure is imported and there is no data, it still occupies a large number of tablespaces, which is indeed a big problem.

4. After importing data to the target database, analyze all tables:

-- Generate a statistical analysis script:

 
 
  1. select 'analyze table '||owner||'.'||table_name ||' compute  statistics; 'from all_tables  
  2. where OWNER in ('GAZX','SJCK','SJPZ','SYWG','HQ','WEBCALL') 

--- Execute the script generated above to update statistics

5. Compress a large number of tablespaces occupied by empty tables:

--- View the space occupied by the table,

 
 
  1. SELECT OWNER,segment_name,SEGMENT_TYPE,BYTES/1024/1024 FROM DBA_SEGMENTS  
  2. WHERE OWNER='GAZX' 
  3. ORDER BY 4 DESC 

--- Check whether data exists in the table

 
 
  1. SELECT * FROM GAZX.GSGG 

--- Check whether the table allows row_movement

 
 
  1. select a.row_movement,a.* from all_tables a 
  2. where  a.owner='GAZX'  AND a.TABLE_NAME='GSGG' 

--- If not, row_movement is enabled.

 
 
  1. alter table GAZX.GSGG enable row movement; 

Generate scripts for batch processing:

 
 
  1. SELECT 'ALTER TABLE GAZX.'||SEGMENT_NAME||' enable row movement;' 
  2. FROM DBA_SEGMENTS  
  3. WHERE OWNER='GAZX' AND SEGMENT_TYPE='TABLE' 

---- Space occupied by the compressed table

 
 
  1. ALTER TABLE  GAZX.GSGG SHRINK SPACE CASCADE; 

Generate scripts for batch processing:

 
 
  1. SELECT 'ALTER TABLE GAZX.'||SEGMENT_NAME||' SHRINK SPACE CASCADE;' 
  2. FROM DBA_SEGMENTS  
  3. WHERE OWNER='GAZX' AND SEGMENT_TYPE='TABLE' 
 

---- After the table is compressed, compress the data file.

6. Check the original and target databases:

Proofread after import:

--- Check the number of tables

 
 
  1. select  OWNER,COUNT(TABLE_NAME) from all_tables  
  2. where OWNER in ('GAZX','SJCK','SJPZ','SYWG','HQ','WEBCALL')  
  3. GROUP BY OWNER 

--- Check the number of Indexes

 
 
  1. SELECT OWNER,COUNT(TABLE_NAME) FROM ALL_INDEXES  
  2. where OWNER in ('GAZX','SJCK','SJPZ','SYWG','HQ','WEBCALL')  
  3. GROUP BY OWNER 

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.