IMP Cross-platform Migration database SQL Generate SQL mode tablespace creation script

Source: Internet
Author: User

When we are using Exp/imp for cross-platform migrations, due to changes in tablespace paths, it is necessary to manually create a table space and data file on the target side that is consistent with the source, and the following is the script to create the generated statement.

one. Execute the following command on the source-side database to generate the Create 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 Tempor ary 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 DAT Abase DataFile ' | | Chr (39) | | A.name | | Chr | | ' 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 | | ' autoextend on; '   From V$tempfile A, v$tablespace bwhere a.ts# = b.ts# and  b.included_in_database_backup= ' NO '

Two. The resulting results are similar to the following:Cases:
Create tablespace system datafile '/oradata/orcl/system01.dbf ' size (m);
Create tablespace undotbs1 datafile '/oradata/orcl/undotbs01.dbf ' size 1630 m;
Create tablespace sysaux datafile '/oradata/orcl/sysaux01.dbf ' size + m;
Create tablespace users datafile '/oradata/orcl/users01.dbf ' size 5 m;
......
Create tablespace zl9indexdev datafile '/oradata/orcl/zl9indexdev.dbf ' size m;
Create tablespace zl9humanbase datafile '/oradata/orcl/zl9humanbase.dbf ' size m;
Create tablespace zl9humaninfo datafile '/oradata/orcl/zl9humaninfo.dbf ' size 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 data file path of the generated statement by replacing it, execute the command on the target side, generate the tablespace and data file, and finally import the data

IMP Cross-platform Migration database SQL Generate SQL mode tablespace creation script

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.