Friday, July 11, 2008

Shell Scripts

Connect to database using Shell script

checkdb.ksh

#Usage: checkdb.ksh ORCLDB
echo $1
sqlplus system@$1/manager<< !
set timing on
set pagesize 100
select name from v\$database;
exit;
!

Steps for splitting and importing

When OS filesize limit set, The dump file can be splitted in to smaller chunks
using split command and imported to database using pipe.

$ split -b2000m devdb.dmp &

$ ls -ltr
total 8393333
-rw-r--r-- 1 hp nobody 1104011840 Feb 22 05:12 xaf
-rw-r--r-- 1 hp nobody 2097152000 Feb 22 05:10 xae
-rw-r--r-- 1 hp nobody 2097152000 Feb 22 05:05 xad
-rw-r--r-- 1 hp nobody 2097152000 Feb 22 05:00 xac
-rw-r--r-- 1 hp nobody 2097152000 Feb 22 04:58 xab
-rw-r--r-- 1 hp nobody 2097152000 Feb 22 04:57 xaa

$ mknod imp_pipe p

$ ls
imp_pipe xaa xab xac xad xae xaf

$ cat xaa xab xac xad xae xaf > imp_pipe &

$imp system/manager@stagedb ignore=y file=imp_pipe log=imp.log fromuser=devuser
touser=stageuser

No comments: