Link to home
Start Free TrialLog in
Avatar of bibi92
bibi92Flag for France

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
Avatar of slightwv (䄆 Netminder)
slightwv (䄆 Netminder)

What part are you having problems with?

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
Avatar of bibi92

ASKER

The script itself is pretty easy:
if schema :
nohup impdp \"/ as sysdba\"  remap_schema=$schema1:$schema2 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
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?
Avatar of bibi92

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
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?
Avatar of bibi92

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.
Avatar of bibi92

ASKER

1 : Instance
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.
Avatar of bibi92

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

>>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.
Avatar of bibi92

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
>>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'?
Avatar of bibi92

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.
Avatar of bibi92

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}_$DATE2.dmp.gz &
            exp userid="'/ as sysdba'" file=$GBL_ADM/tmp/${INSTANCE}_${SCHEMA}_$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/${INSTANCE}_${SCHEMA}_$DATE2.dmp $TYPE statistics=none >>$LOG_EXP 2>&1
fi
bibi
ASKER CERTIFIED SOLUTION
Avatar of slightwv (䄆 Netminder)
slightwv (䄆 Netminder)

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bibi92

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/${INSTANCE}_${SCHEMA}_$DATE2.dmp $TYPE .

exp userid="'/ as sysdba'" file=$CHEMIN_EXP/${INSTANCE}_${SCHEMA}_$DATE2.dmp $TYPE.

Thanks

bibi
Avatar of bibi92

ASKER

Thanks bibi