#!/bin/bash
rm -f /home/impscript/snk.log
chmod -R 777 /home/impscript/snk.dmp
su - oracle -c "/u01/app/product/11.2/bin/sqlplus /nolog" <<EOF
connect / as sysdba
drop user SNKIMP cascade;
drop tablespace SNKIMP including contents and datafiles;
create tablespace SNKIMP logging datafile '/extdisk/orclextdata/snkimp01.dbf' size 200m autoextend on next 50m maxsize 20480m extent management local;
create user SNKIMP identified by SNKIMP default tablespace SNKIMP;
grant connect,resource,dba to SNKIMP;
grant read,write on directory dump_dir to SNKIMP;
exit
EOF
su - oracle -c "impdp SNKIMP/SNKIMP@orcl DIRECTORY=dump_dir DUMPFILE=snk.dmp REMAP_SCHEMA=SNKDATA:SNKIMP logfile=snk.log PARALLEL=4"
rm -f /home/impscript/snk.dmp