You are on page 1of 14

DATABASE EXPORT/IMPORT GUIDE

MetricStream, Inc.
October August 2004
Copyright Notices
2004 Metric Stream, Inc. All Rights Reserved.
The Database Export/Import Guide, as well as the software
described within it, is furnished under license and may only be
used or copied within the terms of that license. The information in
this manual is provided for informational purposes only, is subject
to change without notice, and should not be construed as a
commitment by MetricStream, Inc. MetricStream, Inc. assumes no
responsibility or liability for any errors or inaccuracies that may
appear in this book.

Except as permitted by license, no part of this publication may be


reproduced, stored in a retrieval system, or transmitted, in any
form or by any means – electronic, mechanical, recording, or
otherwise – without the prior written permission of MetricStream,
Inc.

Written and designed at MetricStream, Inc., 3000 Bridge Parkway,


Redwood Shores, CA, 94065, U.S.A.

Printed in the U.S.A

CAUTION
This document contains proprietary, confidential information that
is the exclusive property of MetricStream, Inc. If you do not have a
valid contract with MetricStream for the use of this document, or
have not signed a non-disclosure agreement with MetricStream,
then you received this document in an unauthorized manner and
are not legally entitled to possess or read it.

Use, duplication, and disclosure are subject to restrictions stated in


your contract with MetricStream, Inc. Use, duplication, and
disclosure by the Government are subject to restrictions for
commercial software and shall be deemed to be Restricted Rights
software under Federal Law.

Page ii MetricStream Database Export/Import


Guide
Document Control
This page should be erased in released document. Do not delete
page since that will impact numbering – simply leave the page
empty

Draft copy – not to be distributed to anyone outside MetricStream

Change Record

Date Author Version Change Reference

Aug 4, Bhaskar Version Created


2003 Vasudevan 1.1
Aug 30, Bhaskar Version Fixed minor errors in language
2003 Vasudevan 1.2 and reworded some
statements.
Mar 18, Ashok Kumar Version From the set of Export
2004 Sutradhar 1.4 Commands, changed Direct=Y
to Direct=N & added ‘Note’
before “Steps to Export”
section
Dec 14, Joseph George Version Formatting changes.
2004 1.5
Oct 25, Gagan Arora Version Added
2005 1.9 grant create any type to USER

Signatures

Date Name Signature

MetricStream Database Export/Import Guide


Page iii
Table of Contents
1. EXPORTING AND IMPORTING METRICSTREAM DATABASE
REPOSITORY...................................................................................................................5
ASSUMPTIONS......................................................................................................................5
STEPS TO EXPORT ................................................................................................................6
STEPS TO IMPORT WHEN THE SAME USER NAME USED TO EXPORT THE DATABASE IS USED DURING
THE IMPORT .......................................................................................................................7
STEPS TO IMPORT WHEN THE USER NAME USED TO EXPORT IS DIFFERENT FROM THE USERNAME
USED TO IMPORT...................................................................................................................9
STEPS TO BE EXECUTED AFTER IMPORTING THE DATABASE........................................................12

Page iv MetricStream Database Export/Import


Guide
1. Exporting and Importing MetricStream
Database Repository
Assumptions
Following assumptions are being made (When actually doing the
Import/Export, first gather values for the following parameters),
Examples of the possible values for each parameter is as follows:
1. Database URL (= dbname) – albdms2
2. Export file name – EXPDAT.dmp
3. User (to be exported) – QMSGOLD.
Data Tablespace name (Data to be Imported / Exported resides in
this tablespace) – For example, QMSGOLD_DATA.
Note: The name of the tablespace used has to be the same during
export/import operation. If the database instance from where you
did the export, had the tablespace name as QMSGOLD_DATA, the
same tablespace name should be created and used where the
database will be imported. Not doing so may cause the import to
fail due to Clob columns etc.
Index Tablespace name (Indexes to be Imported / Exported resides
in this tablespace) – QMSGOLD_IDX
Note: This has to be the same during export/import operation. If
the database instance from where you did the export, had the
index tablespace name as QMSGOLD_IDX, the same tablespace
name should be created where the database will be imported.
4. User (name of the user that you would create and setup prior
to importing a database. This user name can be different from
the user specified during export, but in this case you should do
a full import of the database exported. In any case once a user
export has been done, it is always safe to do a full import when
compared to user import. Steps to import the database for
same user and different users is covered separately in this
document in a later section) – MYUSER
5. Password - MYUSER
6. Directory where the MetricStream application is installed
(<INSTALLATION_DIRECTORY>) – C:\MetricStream
7. DB Version – Oracle 8.1.7
Note: If the Oracle repository version is Oracle 8.1.7, make sure
you use EXP client (supplied with Oracle installation) of same or
higher version to do the export. Once the export has been done, to
import the db, make sure you use the same or higher version of

MetricStream Database Export/Import Guide


Page 5
IMP client (supplied with Oracle installation) to do the import. Not
doing so may cause the import to fail due to mismatch in version
of export views.
Note: Please check if the source or target DB is unicode before
starting the export/import process.

Steps to Export
1. Export the database as system/manager. From the DOS
prompt use the following command:
exp system/manager@dbname
For example, with the above mentioned assumptions we can use
the following expression
exp system/manager@devindia

2. Fill in the following fields (The text in underline will appear on


the screen as a prompt and the text following it (after the
greater than arrow) is the answer which is to be provided)
• Enter array fetch buffer size: 4096> Press Enter or give some
value
• Export File: EXPDAT.DMP > Press Enter (in which case it will
create a dump file with the default name, i.e. EXPDAT.dmp) or
provide a file name (if you want to create a dump file with
some other name), which in our case is data.dmp (as per the
assumption made above)
• (1). E(ntire Database), (2) U(sers), or (3) T(ables): (2)U>.
Press Enter to export only the User.
• Export grants (yes/no): yes > Press Enter
• Export table data (yes/no): yes > Press Enter
• Compress extents (yes/no): yes > Press Enter
• User to be exported: (RETURN to quit) > Enter QMSGOLD

3. You can use the following command from command prompt to


do the export.
Exp system/manager@dbname file=EXPDAT.DMP
log=EXPDAT.log compress=N direct=N feedback=1000
statistics=NONE consistent=Y owner=QMSGOLD
For example, with the above mentioned assumptions we can use
the following expression.
Exp system/manager@devindia file=EXPDAT.DMP log=EXPDAT.log
compress=N direct=N feedback=1000 statistics=NONE
consistent=Y owner=QMSGOLD

Page 6 MetricStream Database Export/Import


Guide
Note: MetricStream would recommend using step #9 instead of
#8 to do the export of a db and email the log EXPDAT.log to
MetricStream support for any clarifications.

Steps to Import when the same USER NAME


used to export the database is used during the
import
1. Change working directory to the following –
<INSTALLATION_DIRECTORY>\SYSTEMI\Systemi\database
2. Copy the data dump file (EXPDAT.dmp, obtained after
exporting the db) to this location.
3. Login to sqlplus as –
sqlplus system/manager@albdms2
4. Run the following SQL to find the data files location and note
the data files location
Select file_name, tablespace_name from dba_data_files where
tablespace_name in (‘QMSGOLD_DATA’, ‘QMSGOLD_IDX’);

5. Drop the user QMSGOLD (In case a user with the name
QMSGOLD already exists and the exported database has to be
imported into the same user/schema)
drop user QMSGOLD cascade;
6. Drop the tablespace (In case a tablespace already exists with
the same name and can be replaced with incoming imported
data.)
drop tablespace QMSGOLD_IDX including contents
cascade constraints;
drop tablespace QMSGOLD_DATA including contents
cascade constraints;
Note: If any other schema is sharing the same tablespace, it is
recommended not to use these drop statements. Dropping sub
tablespaces will result in other users/schemas losing the data.
7. Remove the data files from the location obtained in step #4.
Note: If any other schema is sharing the same tablespace, it is
recommended not to use step #6 and #7. Doing so will result in
other users/schemas losing the data.
8. Create tablespace for data file and index file
• Run the following command from sqlplus. This will execute the
file containing commands to create a data tablespace and
index tablespace.
@create_tablespace.sql;

MetricStream Database Export/Import Guide


Page 7
Important: If you are working on a Windows installation, you
may want to use @create_tablespace_nt.sql instead
• While the script is running you will be asked some questions.
Please provide valid inputs for them.
• You will be asked to provide information for the following
1. Enter value for tablespace_data : QMSGOLD_DATA
2. Enter value for datafile_data_path : d:\oracle\oradata
3. Enter value for tablespace_index : QMSGOLD_IDX
4. Enter value for datafile_index_path : d:\oracle\oradata

Important: The tablespace name should be the same as the


exported database’s tablespace name. Path of the datafile can
differ. So, while mentioning the filename in the above, make sure
you use QMSGOLD_DATA and QMSGOLD_IDX

5. Create user QMSGOLD (or another name that you wish to use)
• Run the following command from sqlplus. This will execute the
file containing commands to create a user
@create_user;
• While the script is running you will be asked some questions.
Please provide valid inputs for them.
• Yow will be asked to provide information for the following
1. Enter value for username : QMSGOLD (The username created
above. This user would become the MetricStream repository
userid.
2. Enter value for password: QMSGOLD (The password set for the
user created above.
3. Enter value for default tablespace name: QMSGOLD_DATA
(This would be the data tablespace name created in the
previous step.)
4. Enter temp tablespace name: temp (Usually is TEMP, check
with the DBA)
5. Enter value for tablespace_index: QMSGOLD_IDX
Note: You will not be asked for Default tablespace name and
tablespace_index if you are in the same SQLPLUS session.
• The newly created user needs dba privileges to do the import.
Run the following sql,
grant dba to QMSGOLD;

Page 8 MetricStream Database Export/Import


Guide
• Quite a few application use Types. The newly created user
needs type create privileges. To give this privileage run the
following sql,
grant create any type to QMSGOLD;

6. Logout of sqlplus
7. Import the DMP file as QMSGOLD. From the DOS Prompt use
the following command:
imp QMSGOLD/QMSGOLD@dbname.
For example, with the above assumptions we can use the following
expression: -
imp QMSGOLD/QMSGOLD@albdms2.

8. Fill in the following fields: (The text in underline will appear on


the screen as a prompt and the text following it (after the
greater than arrow) is the answer which is to be provided)
Import File: EXPDAT.DMP > EXPDAT.dmp
Enter insert buffer size <minimum is 8192> 30720 > Press Enter
List contents of import file only (yes/no): no > Press Enter
Ignore create error due to object existence (yes/no): no > Press
Enter
Import grants (yes/no): yes > Press Enter
Import table data (yes/no): yes > Press Enter
Import entire export file (yes/no): no > Press Enter
Username: QMSGOLD
Enter table(T) or partition (T:P) name or .if done: Press Enter

9. You can use the following commands from command prompt to


do the import.
• Imp system/manager@dbname file=EXPDAT.DMP
buffer=30720 commit=Y full=N userid=QMSGOLD/QMSGOLD
log=IMP.log fromuser=QMSGOLD touser=QMSGOLD
• Imp system/manager@devindia file=EXPDAT.DMP
buffer=30720 commit=Y full=N userid=QMSGOLD/QMSGOLD
log=IMP.log fromuser=QMSGOLD touser=QMSGOLD
Note: MetricStream would recommend using step #11 instead of
#10 to do the import of a db and email the log IMP.log to
MetricStream support for any clarifications.

Steps to Import when the USER NAME used to


export is different from the username used to

MetricStream Database Export/Import Guide


Page 9
import
1. Change working directory to the following –
<INSTALLATION_DIRECTORY>\SYSTEMI\Systemi\database

2. Copy the data dump file (EXPDAT.dmp, obtained after


exporting the db) to this location.

3. Login to sqlplus as –
sqlplus system/manager@devindia

4. Drop the user MYUSER (In case a user with the name MYUSER
already exists and the exported database has to be imported in
the same user/schema)
drop user MYUSER cascade;

5. Drop the tablespace (This step assumes that a tablespace


already exists with the same name and can be replaced with
incoming imported data.)
drop tablespace QMSGOLD_IDX including contents cascade
constraints;
drop tablespace QMSGOLD_DATA including contents
cascade constraints;
Note: If any other schema is sharing the same tablespace, it is
recommended not to use these drop statements. Dropping sub
tablespaces will result in other users/schemas losing the data.
• Create tablespace for data file and index file
• Run the following command from sqlplus. This will execute the
file containing commands to create a data tablespace and
index tablespace.
@create_tablespace.sql;

Important: If you are working on a Windows installation, you


may want to use @create_tablespace_nt.sql instead
• While the script is running you will be asked some questions.
Please provide valid inputs for them.
• You will be asked to provide information for the following
1. Enter value for tablespace_data : QMSGOLD_DATA
2. Enter value for datafile_data_path : d:\oracle\oradata
3. Enter value for tablespace_index : QMSGOLD_IDX
4. Enter value for datafile_index_path : d:\oracle\oradata

Page 10 MetricStream Database Export/Import


Guide
Important: Tablespace name should be the same as the
exported database’s tablespace name. Path of the datafile can
differ. So, while mentioning the filename in the above, make sure
you use QMSGOLD_DATA and QMSGOLD_IDX

5. Create user MYUSER


• Run the following command from sqlplus. This will execute the
file containing commands to create a user
@create_user;
• While the script is running you will be asked some questions.
Please provide valid inputs for them.
• Yow will be asked to provide information for the following
6. Enter value for username : MYUSER (The MetricStream
repository userid that you would use or chose during
installation)
7. Enter value for password: MYUSER (The MetricStream
repository userid’s password that you would use or choose
during installation)
8. Enter value for default tablespace name: QMSGOLD_DATA
(Exported data will be imported into this tablespace)
9. Enter temp tablespace name: temp (Usually, check with the
DBA)
10. Enter value for tablespace_index: QMSGOLD_IDX
Note: You will not be asked for Default tablespace name and
tablespace_index if you are in the same SQLPLUS session.
• The newly created user needs dba privileges to do the import.
Run the following sql,
grant dba to MYUSER;
• Quite a few application use Types. The newly created user
needs type create privileges. To give this privileage run the
following sql,
grant create any type to MYUSER;
11. Logout of sqlplus
12. Import the DMP file as myuser. From the DOS Prompt use the
following command:
imp myuser/myuser@dbname.
For example, with the above assumptions we can use the following
expression: -
imp myuser/myuser@devindia.

MetricStream Database Export/Import Guide


Page 11
13. Fill in the following fields: (The text in underline will appear on
the screen as a prompt and the text following it (after the
greater than arrow) is the answer which is to be provided)
Import File:EXPDAT.DMP > EXPDAT.dmp
Enter insert buffer size <minimum is 8192> 30720 > Press Enter
List contents of import file only (yes/no): no > Press Enter
Ignore create error due to object existence (yes/no): no > Press
Enter
Import grants (yes/no): yes > Press Enter

14.You can use the following command from command prompt to


do the import.
Imp system/manager@dbname file=EXPDAT.DMP
buffer=30720 commit=Y full=N userid=QMSGOLD/QMSGOLD
log=IMP.log fromuser=QMSGOLD touser=myuser
Imp system/manager@devindia file=EXPDAT.DMP buffer=30720
commit=Y full=N userid=QMSGOLD/QMSGOLD log=IMP.log
fromuser=QMSGOLD touser=myuser
Note: MetricStream would recommend using step #15 instead of
#14 to do the import of a db and email the log IMP.log to
MetricStream support for any clarifications.

Steps to be executed after importing the


Database
1. Login to the database using the following command: -
username/password@databasename

With the above mentioned assumptions we can use the following


command: -
QMSGOLD/QMSGOLD@albdms2 or
myuser/myuser@albdms2

2. Check for Invalid objects using the query


select object_name, object_type from user_objects where
status like ‘INVALID’;

3. Run db_upgrade_patch.sql (located in <MetricStream


Installation root>/SYSTEMi/Systemi/database directory)
to upgrade the database to the current build, this script
automatically compiles invalid objects and clears them up.
cd <MetricStream Installation
root>/SYSTEMi/Systemi/database>@db_upgrade_patch.s

Page 12 MetricStream Database Export/Import


Guide
ql

We use the following statement to compile invalid database


objects:
Alter <object_type> <object_name> compile
Or alternatively you can do the following
Exec compile_all_invalid_objects

4. Modify the DB URL to current database for MetricStream


Application (Either from the app by logging in and fixing the
application URL in the Edit Application page, or using sqlplus
against the backend)
For example, if the export was done from system14 into
system20, the new URL should be
jdbc:oracle:thin:@system20:1521:albdms2, where it would
originally show jdbc:oracle:thin:@system14:1521:devind14 soon
after the import.

5. Modifying DB URL from the application:

1. Open Internet Explorer browser.


2. In the address bar type the URL of the application.
3. Navigate to the login page.
4. Enter the username and password and the enterprise for
which you want to modify the DB URL.
5. In the application go to the System tab
6. From the list of Existing Enterprises choose the one for which
you want to modify the DB URL, and click the manage
application link.
Usually it is the MetricStream application that should be
modified.
7. From the list of the Existing applications choose that
particular application for which you want to modify the DB
URL and click on the edit application link for that application.
6. In the Edit application page change the following: -
• Database URL (to point to the system and repository in which
you have imported the Database.)
• Modify the database login which you provided at the time of
importing database, i.e. QMSGOLD or myuser

MetricStream Database Export/Import Guide


Page 13
• Modify the database password which you provided at the time
of importing database, i.e. QMSGOLD or myuser

7. Run
<INSTALLATION_DIRECTORY>\SYSTEMi\Systemi\database\alter
_seq.sql
8. Make sure there are no invalid objects or views by re-running
the query mentioned in step 2 above (if some objects are
invalid, check if there are any bugs with the same object by
recompiling the object (Alter <object_type>
<object_name> compile). If the object doesn’t get compiled,
contact MetricStream support).
9. If there are more invalid objects, Run
<INSTALLATION_DIRECTORY>\SYSTEMi\Systemi\database\db_u
pgrade_patch.sql once again to clear these out.

Page 14 MetricStream Database Export/Import


Guide