Thursday, October 22, 2009

How to export/Import Tablespaces in Oracle

Oracle tablespace Export =>

01. Make sure you set the ORACLE_SID or TWO_TASK variable appropriately
02. Login with system/sys user as sysdba
03. Execute below command to find the tablespace you want to export
Select tablespace_name, file_name from dba_data_files;
04. Execute the below command to export the tablespace
exp system/admin tablespaces=ARSYSTEM file=ARSYSTEM.dmp

Oracle Tablespace Import =>
01. Make sure you set the ORACLE_SID or TWO_TASK variable appropriately
02. Login with system/sys user as sysdba
03. Create a dummy tablespace and user before importing the new tablespace with commands
1 In an SQL*Plus window, create the tablespace. For example:
create tablespace arsystem
datafile 'c:\qa\data\QATST\data\arsys.dbf' size 500M reuse;

2 Create a user. For example:
create user aradmin identified by AR#Admin#
default tablespace arsystem
temporary tablespace temp
quota unlimited on arsystem;

3 Create a role for the user you created. For example:
create role ARole_arsys not identified;

4 Set the privileges for the role. For example:
grant alter session, create cluster, create database link, create
sequence, create session, create synonym, create table, create
view, create procedure, create trigger, query rewrite to
ARole_arsys;

5 Grant the role to the user. For example:
grant ARole_arsys to aradmin;

04. Execute the below command to import the tablespace

imp system/admin tablespaces=ARSYSTEM file=ARSYSTEM.dmp FROMUSER=ARADMIN TOUSER=ARADMIN

No comments:

Post a Comment