Thursday, 13 June 2013

Transfer tablespace from one database to other database.

Transfer tablespace from one database to other database.
                there are  many method's to transfer tablespace from one database to other other.In bellow example 
i am using  impdp/expdp  utility to transfer tablespace.

Example:-
               Target Database: orcl
                Source Database: db11g

1] on target database

SQL> create tablespace test
          datafile '/u01/app/oracle/oradata/db11g/test01.dbf' size 10g;
Tablespace created.

SQL> create user test
          identified by test
         default tablespace test;
User created.

SQL> grant connect , resource to test;
 Grant succeeded.

SQL> conn test/test

SQL> create table test(id number);

SQL> begin
         for i in 1..10 loop
        insert into test values(i);
        end loop;
        end;
/
SQL> commit;

SQL>select count(*) from test;


  COUNT(*)
----------
         10




SQL> !



[oracle@orcl]$ expdp directory=expdp dumpfile=exp_tablespace.dmp logfile=exp_tablespace.log tablespaces=test


Export: Release 11.2.0.1.0 - Production on Fri Jun 14 16:40:16 2013

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

Username: /as sysdba


Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "SYS"."SYS_EXPORT_TABLESPACE_01":  /******** AS SYSDBA directory=expdp dumpfile=exp_tablespace.dmp logfile=exp_tablespace.log tablespaces=test
Estimate in progress using BLOCKS method...
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 128 KB
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
. . exported "TEST"."TEST"                               5.070 KB      10 rows

Master table "SYS"."SYS_EXPORT_TABLESPACE_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SYS.SYS_EXPORT_TABLESPACE_01 is:
  /u01/expd/exp_tablespace.dmp
Job "SYS"."SYS_EXPORT_TABLESPACE_01" successfully completed at 16:40:37


2] copy dumpfile to source database using ftp,hard drive etc....(/u01/expdp).

3] on source database.

[oracle@db11g]$ sqlplus

SQL*Plus: Release 11.2.0.1.0 Production on Fri Jun 14 16:14:12 2013

Copyright (c) 1982, 2009, Oracle.  All rights reserved.

Enter user-name: /as sysdba

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL>create directory expdp as '/u01/expdp'

SQL> create tablespace test
          datafile '/u01/app/oracle/oradata/db11g/test01.dbf' size 10g;

Tablespace created.

SQL>create user test
          identified by test
         default tablespace test;

user created

SQL> grant connect , resource to test;
 Grant succeeded.

SQL>exit


[oracle@db11g]$impdp  directory=EXPDP dumpfile=exp_tablespace.dmp logfile=exp_tablespace.log full=y

Import: Release 11.2.0.1.0 - Production on Fri Jun 14 16:18:26 2013

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

Username: /as sysdba

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

................
..............

[oracle@db11g]$ exit

SQL> conn test/test

SQL> select count(*) from test;

  COUNT(*)
----------
         10






No comments:

Post a Comment

work on autovacuum postgreSQL parameter

 In This blog, we are discussing the auto vacuum parameter on a small scale. we will understand the below parameters and will see how to mod...