bibi92
asked on
script shell impdp
Hello,
I search a shell script for doing an impdp for a schema or a table with parameters.
Thanks
bibi
I search a shell script for doing an impdp for a schema or a table with parameters.
Thanks
bibi
ASKER
The script itself is pretty easy:
if schema :
nohup impdp \"/ as sysdba\" remap_schema=$schema1:$sch ema2 network_link=$dblink buffer=100000 COMMIT=Y recordlength=65535 LOGFILE=logname.log
if table
nohup impdp \"/ as sysdba\" TABLES=$tablename network_link=$dblink buffer=100000 COMMIT=N recordlength=65535 LOGFILE=logname.log
if dataonly
nohup impdp \"/ as sysdba\" TABLES=$tablename network_link=$dblink CONTENT=DATA_ONLY COMMIT=Y buffer=100000 recordlength=65535 LOGFILE=logname.log
Thanks
bibi
if schema :
nohup impdp \"/ as sysdba\" remap_schema=$schema1:$sch
if table
nohup impdp \"/ as sysdba\" TABLES=$tablename network_link=$dblink buffer=100000 COMMIT=N recordlength=65535 LOGFILE=logname.log
if dataonly
nohup impdp \"/ as sysdba\" TABLES=$tablename network_link=$dblink CONTENT=DATA_ONLY COMMIT=Y buffer=100000 recordlength=65535 LOGFILE=logname.log
Thanks
bibi
I do not understand the 'if' parts.
Are you wanting to pass in a single parameter to the script that will select one of those types of import?
Will you have already exported the 'schema' and/or 'tablename' variables or will you be passing them in as well?
Are you wanting to pass in a single parameter to the script that will select one of those types of import?
Will you have already exported the 'schema' and/or 'tablename' variables or will you be passing them in as well?
ASKER
if $table or if the user want to import the structure and the datas.
if $schema or if the user want to import the schema.
iif $dataonly or if the user want to import only the datas.
I transfer the datas with network_link=$dblink
Thanks
bibi
if $schema or if the user want to import the schema.
iif $dataonly or if the user want to import only the datas.
I transfer the datas with network_link=$dblink
Thanks
bibi
That doesn't really answer my question.
Are you wanting them to be passed in as parameters to the shell script or are you going to be setting them externally before you call the script?
Are you wanting them to be passed in as parameters to the shell script or are you going to be setting them externally before you call the script?
ASKER
Yes, I want them to be passed in as parameters. Thanks
I need the requirements.
What are the parameters to look like? How is it to work?
For example what is the first parameter to be? If it is just some 'word' how do I know if it is a table or a schema?
It sounds like you don't have complete requirements or a design in mind. Once you have that we can help.
It is hard for us to help with the design since we do don't understand your system or requirements.
What are the parameters to look like? How is it to work?
For example what is the first parameter to be? If it is just some 'word' how do I know if it is a table or a schema?
It sounds like you don't have complete requirements or a design in mind. Once you have that we can help.
It is hard for us to help with the design since we do don't understand your system or requirements.
ASKER
1 : Instance
2 : Table or schema
3 : Data_only or structure
Thanks
Bibi
2 : Table or schema
3 : Data_only or structure
Thanks
Bibi
I need a more descriptive explanation.
"1 : Instance" doesn't tell me anything.
This is even further confusing when you add an 'or' like in #2 since the impdp commands are different.
I would suggest you hire a local consultant to come in and work on this with you. They would be able to better understand your requirements if they were onsite with you.
"1 : Instance" doesn't tell me anything.
This is even further confusing when you add an 'or' like in #2 since the impdp commands are different.
I would suggest you hire a local consultant to come in and work on this with you. They would be able to better understand your requirements if they were onsite with you.
ASKER
1 : Instance = Oracle instance name
This is even further confusing when you add an 'or' like in #2 since the impdp commands are different :
Or is used for explain the parameter :
If $table or if the user want to import the structure and the datas.
if $schema or if the user want to import the schema.
iif $dataonly or if the user want to import only the datas.
Thanks
bibi
This is even further confusing when you add an 'or' like in #2 since the impdp commands are different :
Or is used for explain the parameter :
If $table or if the user want to import the structure and the datas.
if $schema or if the user want to import the schema.
iif $dataonly or if the user want to import only the datas.
Thanks
bibi
>>Or is used for explain the parameter
I understand you want to use parameters. I'm not unserstanding the specifics.
Say your script is called 'myscript.ksh'.
Give me some examples of how you are wanting to call it using the parameters.
For example:
for a table I would like to do:
myscript.ksh ??? ??? ???
for a schema:
myscript.ksh ??? ??? ???
where ??? are the parameters you are thinking about.
I understand you want to use parameters. I'm not unserstanding the specifics.
Say your script is called 'myscript.ksh'.
Give me some examples of how you are wanting to call it using the parameters.
For example:
for a table I would like to do:
myscript.ksh ??? ??? ???
for a schema:
myscript.ksh ??? ??? ???
where ??? are the parameters you are thinking about.
ASKER
for a table I would like to do:
myscript.ksh $tablename
or
myscript.ksh $tablename $data_only
for a schema:
myscript.ksh $schema_source $schema_cible
Thanks
bibi
myscript.ksh $tablename
or
myscript.ksh $tablename $data_only
for a schema:
myscript.ksh $schema_source $schema_cible
Thanks
bibi
>>for a table I would like to do:
Given:
myscript.ksh $tablename $data_only
before you call the script you will do:
export tablename='some_value'
and for
myscript.ksh $schema_source $schema_cible
export schema_source='some_value'
Please clarify.
If so, there is no way to do this because once inside the script how will you be able to tell the first parameter is a 'table', or a 'schema'?
Given:
myscript.ksh $tablename $data_only
before you call the script you will do:
export tablename='some_value'
and for
myscript.ksh $schema_source $schema_cible
export schema_source='some_value'
Please clarify.
If so, there is no way to do this because once inside the script how will you be able to tell the first parameter is a 'table', or a 'schema'?
ASKER
maybe can I use case in the script for do an import for a table or a schema. Thanks bibi
You are not understanding what I am saying.
Once inside the script, how do you know if the first parameter is the name of a table or the name of a schema?
By using the '$', $tablename and $schema_source appear to be environment variables in Unix. They resolve to some 'string'.
I was trying to get you to understand your requirements and what you are really wanting to do.
You need some way to tell the script 'what' you are doing.
For example, the first parameter could be the 'what':
myscript.ksh TABLE $tablename $data_only
myscript.ksh SCHEMA $schema_source $schema_cible
Then you can use a case statement or simple if-then-else.
Once inside the script, how do you know if the first parameter is the name of a table or the name of a schema?
By using the '$', $tablename and $schema_source appear to be environment variables in Unix. They resolve to some 'string'.
I was trying to get you to understand your requirements and what you are really wanting to do.
You need some way to tell the script 'what' you are doing.
For example, the first parameter could be the 'what':
myscript.ksh TABLE $tablename $data_only
myscript.ksh SCHEMA $schema_source $schema_cible
Then you can use a case statement or simple if-then-else.
ASKER
Example of a part of script I do for export schema :
if [ $COMPRESSION = "Y" -o $COMPRESSION = "y" ]
then
mknod 1>/dev/null 2>&1
if [ "$?" -eq 2 ]
then
mknod $GBL_ADM/tmp/${INSTANCE}_$ {SCHEMA}_$ DATE2.dmp p
gzip -c < $GBL_ADM/tmp/${INSTANCE}_$ {SCHEMA}_$ DATE2.dmp > $CHEMIN_EXP/${INSTANCE}_${ SCHEMA}_$D ATE2.dmp.g z &
exp userid="'/ as sysdba'" file=$GBL_ADM/tmp/${INSTAN CE}_${SCHE MA}_$DATE2 .dmp $TYPE statistics=none >>$LOG_EXP 2>&1
rm -f $GBL_ADM/tmp/${INSTANCE}_$ {SCHEMA}_$ DATE2.dmp
else
ECHOLOG ": fin: echec: The command mknod does not exist"
exit 3
fi
else
exp userid="'/ as sysdba'" file=$CHEMIN_EXP/${INSTANC E}_${SCHEM A}_$DATE2. dmp $TYPE statistics=none >>$LOG_EXP 2>&1
fi
bibi
if [ $COMPRESSION = "Y" -o $COMPRESSION = "y" ]
then
mknod 1>/dev/null 2>&1
if [ "$?" -eq 2 ]
then
mknod $GBL_ADM/tmp/${INSTANCE}_$
gzip -c < $GBL_ADM/tmp/${INSTANCE}_$
exp userid="'/ as sysdba'" file=$GBL_ADM/tmp/${INSTAN
rm -f $GBL_ADM/tmp/${INSTANCE}_$
else
ECHOLOG ": fin: echec: The command mknod does not exist"
exit 3
fi
else
exp userid="'/ as sysdba'" file=$CHEMIN_EXP/${INSTANC
fi
bibi
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hello,
I think I have to close this post and I have to modify the exp command by impdp and change the variables like file=$CHEMIN_EXP/${INSTANC E}_${SCHEM A}_$DATE2. dmp $TYPE .
exp userid="'/ as sysdba'" file=$CHEMIN_EXP/${INSTANC E}_${SCHEM A}_$DATE2. dmp $TYPE.
Thanks
bibi
I think I have to close this post and I have to modify the exp command by impdp and change the variables like file=$CHEMIN_EXP/${INSTANC
exp userid="'/ as sysdba'" file=$CHEMIN_EXP/${INSTANC
Thanks
bibi
ASKER
Thanks bibi
What parameters will you be passing into the sript?
Do you have the impdp command you need?
The script itself is pretty easy:
#/usr/bin/ksh
export ORACLE_SID=ORCL
export ORAENV_ASK=NO
. oraenv
impdp ............ the rest of the command