Sei sulla pagina 1di 4

Documentation on Importing and Exporting of Schemas

Objective: This document explains the different steps for importing and exporting of the
schemas.

Scope: This document has been prepared for exclusive use at Cholamandalam DBS.

-----********************************************
----- STEP 1 **** Exporting Schema
-----********************************************

export ORACLE_SID=CDCASUAT

./exp bacuser/bacuser owner=NUCPRODCAS file=/oracle/nucprodcas.dmp


log=/oracle/nucprodcas.log touser=NUCPRODCAS statistics=none direct=y
consistent=y

-----********************************************
----- STEP 2 **** Connect as SYS user
-----********************************************

export ORACLE_SID=CHOLASIT
sqlplus /nolog
conn SYS as sysdba

-----********************************************
----- STEP 3 **** Tablespace Free space
-----********************************************

---Check tablespace free space (including undo tablespace and temporary tablespace)

select tablespace_name, sum(bytes)/1024/1024 from dba_free_space group by


tablespace_name;
select tablespace_name, sum(bytes_free)/1024/1024 from v$temp_space_header group
by tablespace_name;

Wipro-CDBS Confidential Internal Circulation Only


4
-----********************************************
----- STEP 4 **** CREATING USER
-----********************************************

Create user NUCPRODCAS identified by xyz#0000;

grant connect, resource to NUCPRODCAS;


alter user NUCPRODCAS default tablespace TBS_USR_CAS01;
alter user NUCPRODCAS temporary tablespace temporary_data;
alter user NUCPRODCAS quota unlimited on TBS_USR_CAS01;
Grant CREATE SESSION To NUCPRODCAS;
Grant ALTER SESSION To NUCPRODCAS;
Grant UNLIMITED TABLESPACE To NUCPRODCAS;
Grant CREATE TABLE To NUCPRODCAS;
Grant CREATE CLUSTER To NUCPRODCAS;
Grant CREATE SYNONYM To NUCPRODCAS;
Grant CREATE VIEW To NUCPRODCAS;
Grant CREATE SEQUENCE To NUCPRODCAS;
Grant CREATE DATABASE LINK To NUCPRODCAS;
Grant CREATE PROCEDURE To NUCPRODCAS;
Grant CREATE TRIGGER To NUCPRODCAS;
Grant CREATE TYPE To NUCPRODCAS;
Grant CREATE OPERATOR To NUCPRODCAS;
Grant CREATE INDEXTYPE To NUCPRODCAS;
Grant SELECT On SYS.V_$SESSION To NUCPRODCAS;
Grant SELECT On SYS.V_$DATABASE To NUCPRODCAS;
Grant SELECT On SYS.V_$INSTANCE To NUCPRODCAS;
Grant SELECT On SYS.DBA_INDEXES To NUCPRODCAS;
Grant SELECT On SYS.DBA_OBJECTS To NUCPRODCAS;
Grant SELECT On SYS.DBA_ROLE_PRIVS To NUCPRODCAS;
Grant SELECT On SYS.DBA_USERS To NUCPRODCAS;
Grant QUERY REWRITE To NUCPRODCAS;
Grant CREATE LIBRARY To NUCPRODCAS;
GRANT SELECT ON DBA_USERS TO NUCPRODCAS;
GRANT SELECT ON DBA_OBJECTS TO NUCPRODCAS;
GRANT SELECT ON DBA_INDEXES TO NUCPRODCAS;
GRANT SELECT ON DBA_ROLE_PRIVS TO NUCPRODCAS;

-----********************************************
----- STEP 5 **** IMPORTING THE DUMP
-----********************************************
-----Monitor tablespace free space

export ORACLE_SID=CHOLASIT

Wipro-CDBS Confidential Internal Circulation Only


4
./imp bacuser/bacuser file=/oracle/nucprodcas.dmp log=/oracle/nucprodcas.log
fromuser=NUCPRODCAS touser=NUCPRODCAS grants=n statistics=none ignore=n
indexes=n indexfile=/oracle/indexnuc.txt

----********************************************************
---- STEP 6 Comparing objects after Import
----**********************************************************

Check the import log For the rows imported in table and errors

Check the count of imported objects and compare it from UAT schema

Select count(*), object_type from user_objects group by object_type;


Select table_name, num_rows from user_tables where owner=USERNAME;

----********************************************************
---- STEP 7 - Rebuild Indexes - NUCPRODCAS
----**********************************************************

---Login as New NUCPRODCAS


---Run the generated indexfile script created from import

@/oracle/indexnuc.txt

----Rebuild indexes

select 'ALTER INDEX '|| index_name || ' REBUILD ONLINE;' from user_indexes;

----*******************************************************************
----- STEP 8 **** Grants of exported NUCPRODCAS(UAT) to new NUCPRODCAS
-----******************************************************************

----Login into NUCPRODCAS (UAT) and give grants to new NUCPRODCAS;


set heading off;
set pages 0;
set line 100;
spool c:\grant.sql;
select 'Grant '|| privilege ||' on '|| grantor || '.' || table_name || ' to '|| grantee || ';' from
dba_tab_privs where grantee='NUCPRODCAS';

select 'Grant all on '||'vf.' || object_name || ' to '|| 'VFMIGR' ||


';' from dba_objects where owner='VF';
spool off;

Wipro-CDBS Confidential Internal Circulation Only


4
---Login as New NUCPRODCAS
@c:\grant.sql;

-----******************************************************
----- STEP 9 **** COMPILING FOR INVALID OBJECTS (REPEAT)
-----******************************************************

Login as New NUCPRODCAS and run the following command till you get no rows
selected.

set heading off;


spool c:\comp.sql;
select 'Alter ' || Object_Type || ' ' || object_name || ' Compile;'
from user_objects
where status <> 'VALID';
spool off;
@c:\comp.sql;

-----********************************************
----- STEP 10 **** Database Links
-----********************************************

Create Database links if required.

-----********************************************
----- STEP 11 **** Analyzing Schema
-----********************************************

conn / as sysdba

Exec Dbms_STATS.GATHER_Schema_STATS('NUCPRODCAS');

-----********************************************
----- END
-----********************************************

Wipro-CDBS Confidential Internal Circulation Only


4

Potrebbero piacerti anche