Copying only schema definition to another schema
NOTE: Names of tablespaces on both the schema should be same, otherwise import will fail indicating oracle error
Hello World. This is my First of First Blog. Here I will try to write things related to what I learn, Since I am kinda obsessed with Technology’s lineage. I, being a Java professional, love Java profoundly and so tried to make a blog that will help you and me of course to be in touch with new happenings in the field of technology. I may soon start a discussion forum based on Java, for that we need to wait a while, after all , not always, good things are FREE….
Here is the bash script that does the job of export and import of an oracle schema to another schema.
Save this file as EXPORT_IMPORT.
For exporting the schema type
EXPORT_IMPORT EXP
This file generates the schema dump in exp_database.dmp file and it also makes log of export process in exp_database.log file.
For importing the same exported exp_database.dmp dump file to another schema type
EXPORT_IMPORT IMP
if [ $# -lt 1 ]; then
echo "First argument to this file should be either EXP or IMP."
exit
fi
if [ "$1" = "EXP" ]; then
if [ $# != 2 ]; then
echo "No of arguments to this file should be two."
echo "USAGE: EXPORT_IMPORT EXP
exit
fi
exp "$2" FILE=exp_database.dmp COMPRESS=N CONSISTENT=N CONSTRAINTS=Y GRANTS=Y INDEXES=Y RECORD=Y ROWS=Y Feedback=1000 LOG=exp_database.log
fi
if [ "$1" = "IMP" ]; then
if [ $# != 3 ]; then
echo "No of arguments to this file should be three."
echo "USAGE: EXPORT_IMPORT IMP
exit
fi
from_user=`echo "$2" | cut -f1 -d'/'`
to_user=`echo "$3" | cut -f1 -d'/'`
imp userid="$3" fromuser="$from_user" touser="$to_user" file=exp_database.dmp buffer=64000 commit=y
fi
Here we will first create a tablespace and then we will create a user for that tablespace.
create tablespace ahsan
add datafile 'e:\ahsan.dbf' size 100 m;
create user ahsan identified by welcome
default tablespace ahsan temporary tablespace temp;
grant create session, connect, resource to ahsan;
Hence now you are ready with the new tablespace and a new user that belongs to the ahsan tablespace;
Posted by Unknown at 8:59 AM 0 comments
Labels: oracle, schema, tablespace