Thursday, 2 May 2013

Oracle Export ( exp ) / Import ( imp ) With Full DB and Schema Refresh Steps

    
ORACLE DATABASE BACKUPS:

Backup and recovery is one of the most important aspects of a DBA's job. If you lose your company's data, you could very well lose your job. Hardware and software can always be replaced, but your data may be irreplaceable!


Types of Backup:

1. Logical backup (exp/imp --> 9i , expdp/impdp --> 10g)
2. Physical backup

2.A) User Managed backup( Cold and Hot backup)
2.B) Server Manager backup( RMAN - Recovery Manager )


1. Logical backup (exp/imp)
====================

We can take export(exp) in four levels.

1A. Full database Level export/import
1B. Schema(User) Level export/import
1C. Table Level export/import
1D. Tablespace Level export/import


Note: Do the export in Source(ctsp) database and import in target(ctsd) database.

      Database must be in open.


1A. Full database Level export/import
=====================================

exp system/manager file='/u01/app/oracle/ctsfull.dmp' log='/u01/app/oracle/ctsfull.log' full=y

imp system/manager file='/u01/app/oracle/ctsfull.dmp' log='/u01/app/oracle/ctsfull_imp.log' full=y



1B. Schema(User) Level export/import
====================================
exp system/manager file='/u01/app/oracle/ctsuser.dmp' log='/u01/app/oracle/ctsuser.log' owner=raja

imp system/manager file='/u01/app/oracle/ctsuser.dmp' log='/u01/app/oracle/ctsuser_imp.log' fromuser=raja touser=raja

Note: RAJA is a user in the database


1C. Table Level export/import
=============================


exp system/manager file='/u01/app/oracle/ctstab.dmp' log='/u01/app/oracle/ctstab.log' tables=raja.emp


imp system/manager file='/u01/app/oracle/ctstab.dmp' log='/u01/app/oracle/ctstab_imp.log' fromuser=raja touser=raja tables=emp


DB Refresh steps:
=================

1. take export of source database(ctsp).

exp system/manager file='/u01/app/oracle/ctsfull.dmp' log='/u01/app/oracle/ctsfull.log' full=y


2. move the dumpfile to target database(ctsd) using scp.. if both the database running in same server this steps is not required.

scp /u01/app/oracle/ctsfull.dmp oracle@<Target server IP>:/u02/app/oracle


3. Drop the application users and dont drop database default users like sys,system,dbsnmb,xdb.

If you give below command it will show username,created date. Mostly database default users will be created in same day.

select username,created from dba_users;

drop user raja cascade;


4. Befor doing import check the used space of source database and freespace in the target database. tablespaces names should same between sourec and target database then Target database each tablespace size should be more than or equal to source database tablespace.

Source:

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

Target:

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

5. Start the import in taget database.


imp system/manager file='/u01/app/oracle/ctsfull.dmp' log='/u01/app/oracle/ctsfull_imp.log' full=y


6. once competed compare the object counts between source and target databases.

select object_type,count(*) from dba_objects where status='VALID' group by object_type;

=============================== end ===========================



Schema Refersh steps:
=====================

1. take export of a schema in source database(ctsp).

exp system/manager file='/u01/app/oracle/ctsuser.dmp' log='/u01/app/oracle/ctsuser.log' owner=raja

Note: Dont give semicolon(;) at the end of the above command.

2. move the dumpfile to target database(ctsd) using scp.if both the database running in same server this steps is not required.

scp /u01/app/oracle/ctsuser.dmp oracle@<Target server IP>:/u02/app/oracle


3. create the new user in target database(if already existed drop and recreate)

select username from dba_users;

drop user raja cascade;

create user raja identified by raja;


4. befor doing import check the used space of a schema(user) in source database and freespace in the target database then target

database tablespaces should be more than or equal to source database tablespaces.

Source:

select tablespace_name,sum(bytes/1024/1024) from dba_segments where owner='RAJA' group by tablespace_name;

Target:

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


5. Start the import in taget database.


imp system/manager file='/u01/app/oracle/ctsuser.dmp' log='/u01/app/oracle/ctsuser_imp.log' fromuser=raja touser=raja


6. once competed compare the object counts between source and target databases.

select object_type,count(*) from dba_objects where owner='RAJA' and status='VALID' group by object_type;

17 comments:


  1. Air Fright
    I appreciate the ideas and this is very nice article and have great information.and NTL Logistics Plus is also Logistics Company in India provides Transportation

    Services in India.Thanks for great information you write it very clean. I am very lucky to get this tips from you

    ReplyDelete
  2. really crystal clear tips i got here ...

    ReplyDelete
  3. Hello, I love reading through your blog, I wanted to leave a little comment to support you and wish you a good continuation. Wish you best of luck for all your best efforts..Import Procedure Chennai

    ReplyDelete
  4. Thx a lot For sharing such a nice information on
    Oracle 11g DBA Online Training

    ReplyDelete
  5. It is an amazing post.Very useful to me.I liked it .And Swipe Your Credit Card And have Immediate cash With Cheapest Costs.
    Provide Your ID Card Photo Copy As A Document Resistant.If you Want more details kindly Visit Here

    ReplyDelete
  6. Hi,

    Thanks for sharing this blog.

    ReplyDelete
  7. thanks for sharing this valuable information
    Oracle Course

    ReplyDelete
  8. Your blog is so nice, and the article is very good it helps to so many people.
    Oracle DBA Training in Hyderabad

    ReplyDelete
  9. good blog .The important thing is that in this blog content written clearly and understandable. The content of information is very informative.oracle training in chennai

    ReplyDelete
  10. Get Oracle Certification in Chennai for making your career as a shining sun with Infycle Technologies. Infycle Technologies is the best Oracle training institute in Chennai, providing complete hands-on practical training of professional specialists in the field. In addition to that, it also offers numerous programming language tutors in the software industry such as Big Data, Java, Python, AWS, Hadoop, etc. Once after the training, interviews will be arranged for the candidates, so that, they can set their career without any struggle. Of all that, 200% placement assurance will be given here. To have the best career, call 7502633633 to Infycle Technologies and grab a free demo to know more.Best Oracle Training Institute in Chennai

    ReplyDelete
  11. Reach to the
    best Data Science Training in Chennai
    , Infycle Technologies, to enter the IT industry with well-defined skills. Infycle Technologies is the rapidly developing software training cum placement center in Chennai and is generally known for its significance in providing quality hands-on practical training with 200% guaranteed outcomes! Call 7502633633 to book a free demo and to avail the best offers.

    ReplyDelete
  12. Infycle Technologies, the best software training institute in Chennai offers the No.1 Python Certification in Chennai for tech professionals. Apart from the Python Course, other courses such as Oracle, Java, Hadoop, Selenium, Android, and iOS Development, Big Data will also be trained with 100% hands-on training. After the completion of training, the students will be sent for placement interviews in the core MNC's. Dial 7502633633 to get more info and a free demo.

    ReplyDelete