Friday, 15 April 2011

windows - How create Batch script to automate DB Dump import into Oracle 11g database with username and password? -



windows - How create Batch script to automate DB Dump import into Oracle 11g database with username and password? -

i need create batch script these next tasks:

drop oracle user

create oracle user user

grant permission dba sqlplus cammand prompt

importing oracle 11g dump

and command prompt want import oracle 11g dump.

in normal way these steps follow always:

step 1: open command prompt , start sql*plus:

c:\user>sqlplus sys/sys@mysid sysdba;

step 2: droping existing user

sql:> drop user test cascade;

step 3: creating user , granting dba permission,

sql:> create user test identified test123 default tablespace users temporary tablespace temp quota unlimited on users; sql:> grant dba test; sql:> commit; sql:> exit;

step 4: command prompt importing oracle dump on newly created user.

imp userid ='test/test123@mysid' file='d:\dumps\oracle\imported\exp_test1_at_mydev_20121108.dmp' log='d:\dumps\oraclelog\newimp160913_run.log' rows=y full=y ignore=y;

using these above steps able drop user, create user , import oracle 11g dump successfully.

i need these tasks using batch script.

as sqlplus script (thebatch.sql):

drop user test cascade; create user test identified test123 default tablespace users temporary tablespace temp quota unlimited on users; grant dba test; host imp userid ='test/test123@mysid' file='d:\dumps\oracle\imported\exp_test1_at_mydev_20121108.dmp' log='d:\dumps\oraclelog\newimp160913_run.log' rows=y full=y ignore=y; quit

now, i'm not dos scripting expert, have sql script (the_drop_crt_user.sql) follows:

drop user test cascade; create user test identified test123 default tablespace users temporary tablespace temp quota unlimited on users; grant dba test; quit

then dos script runs sql script , runs imp:

sqlplus sys/sys@mysid sysdba @ the_drop_crt_user.sql imp userid=.....

windows oracle batch-file oracle11g

No comments:

Post a Comment