IMP cross-platform Migration Database SQL generation SQL method tablespace creation script, impsql

Source: Internet
Author: User

IMP cross-platform Migration Database SQL generation SQL method tablespace creation script, impsql

When using EXP/IMP for cross-platform migration, we need to manually create the tablespace and data files consistent with the source at the target end due to the tablespace path change, the following is the script used to create the statement.

1. Run the following command in the source database to generate the creation script

select 'create tablespace ' || b.NAME || ' DATAFILE ' || chr(39) || a.NAME || chr(39) || ' SIZE ' || a.BYTES / 1024 / 1024 || ' m;'  from v$datafile a, v$tablespace bwhere a.ts# = b.TS# And b.INCLUDED_IN_DATABASE_BACKUP='YES'Union Allselect 'Create Temporary Tablespace ' || b.NAME || ' Tempfile ' || chr(39) || a.NAME ||chr(39) || ' SIZE ' || a.BYTES / 1024 / 1024 || ' m;'  from v$tempfile a, v$tablespace bwhere a.ts# = b.TS# And b.INCLUDED_IN_DATABASE_BACKUP='NO'Union Allselect  'alter database datafile ' ||chr(39) ||a.NAME ||chr(39)||' autoextend on ;'   from v$datafile a, v$tablespace bwhere a.ts# = b.TS# And  b.INCLUDED_IN_DATABASE_BACKUP='YES'Union Allselect  'alter database Tempfile ' ||chr(39) ||a.NAME ||chr(39)||' autoextend on ;'   from v$tempfile a, v$tablespace bwhere a.ts# = b.TS# And  b.INCLUDED_IN_DATABASE_BACKUP='NO'

II. The generated results are similar to the following: Example:
Create tablespace system datafile '/oradata/orcl/system01.dbf' size 1000 m;
Create tablespace undotbs1 datafile '/oradata/orcl/undotbs01.dbf' size 1630 m;
Create tablespace sysaux datafile '/oradata/orcl/sysaux01.dbf' size 1000 m;
Create tablespace users datafile '/oradata/orcl/users01.dbf' size 5 m;
......
Create tablespace zl9indexdev datafile '/oradata/orcl/zl9indexdev. dbf' size 20 m;
Create tablespace zl9humanbase datafile '/oradata/orcl/zl9humanbase. dbf' size 20 m;
Create tablespace zl9humaninfo datafile '/oradata/orcl/zl9humaninfo. dbf' size 20 m;
.......
Alter database datafile '/oradata/orcl/system01.dbf' autoextend on;
Alter database datafile '/oradata/orcl/undotbs01.dbf' autoextend on;
Alter database datafile '/oradata/orcl/sysaux01.dbf' autoextend on;
Alter database datafile '/oradata/orcl/users01.dbf' autoextend on;
......
Alter database tempfile '/oradata/orcl/zltoolstmp. dbf' autoextend on;
Modify the path of the data file of the statement generated by replacing the statement, execute the command on the target end, generate the tablespace and data file, and then import the data.

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.