Expandmenu Shrunk


分享一Oracle脚本

在日常的DBA管理中,shell的使用可以快速、高效、安全的进行一些维护工作。下面分享下笔者迁移数据库环节中的一些脚本,以供学习交流。

 

#!/bin/sh
#Note
#Author:LengBo
#Time:20120423
#Purpose:For EXP/IMP
#conn_str=vm_fsxybak
conn_str=peppdb
echo  “Please enter you username with DBA privilegs,default system:”
read username
echo “Username is: $username”
echo  “Please enter you password:”
read password
echo “Password Is:$password”
echo -n “Enter you choice: y[yes]; n[no]:”
sleep 10

read choice
case $choice in
y|yes)
     result=1
;;
n|no)
     result=0
;;
esac

if [ $result -ne 0 ]
   then
source ~/.bash_profile
sqlplus  $username/$password@${conn_str}  <<EOF
set head off;
set echo off;
set lin 200;
spool ‘/tmp/dis_pk.sql’;

select ‘ alter table  ‘||s.owner||’.’|| table_name  ||’ disable primary key cascade;’
from dba_constraints s
where s.constraint_type=’P’
and s.owner  in(‘PEPP_COMMON’,’PEPP_TAPS’,’PEPP_PE’,’PEPP_CUSTSVC’,’PEPP_BMS’,’PEPP_STT’,’PEPP_RISKMAN’,’PEPP_B2B’,’PEPP_WP’)
and s.owner not in(‘SYS’,’SYSTEM’,’SYSMAN’);

spool off;
EOF

more /tmp/dis_pk.sql | sed ‘/^$/d’ | sed ‘1d’|sed ‘1d’ |more |sed ‘$d’|sed ‘$d’ > /tmp/tmp.sql

sqlplus  $username/$password@${conn_str}  <<EOF
set timing on;
prompt Now Staring Disable All triggers:
set timing on
execute dbms_lock.sleep(5);
@/tmp/tmp.sql;
EOF

if [ $? -eq 0 ]
    then echo “Note:Disable PK Succeed!”
fi

cd /tmp && rm *.sql
else
   echo “Not proceding,Now exiting!”
   exit
fi


42 Responses to 分享一Oracle脚本

  1. 分享一Oracle脚本 « Oracle小筑 lunettes oakley pas cher http://www.87wg.com
    http://www.87wg.com

  2. I’m not that much of a internet reader to be honest
    but your sites really nice, keep it up! I’ll go ahead and bookmark your website to come back down the road. All the best

    my web site: Rosie Vonderheide

  3. 週間売れ筋商品の1位 ~20位をご紹介しています!楽天市場でヒットして いる話題の商品や人気商品などをご購入いただけます3458463643 Dfdsg
    ルイヴィトン 群馬 http://www.theenidi.com/%e3%83%ab%e3%82%a4%e3%83%b4%e3%82%a3%e3%83%88%e3%83%b3-%e7%be%a4%e9%a6%ac-%e6%96%b0%e3%81%97%e3%81%84-%e3%83%ab%e3%82%a4%e3%83%b4%e3%82%a3%e3%83%88%e3%83%b3-%e8%b2%a1%e5%b8%83-%e6%9c%80%e3%82%82
    ルイヴィトン 群馬

  4. When starting a training program, find your maximum heart rate initially, then stay within 50 to 85 percent of this in subsequent sessions, a range known as your target heart rate. Nike Free 7.0 http://www.ravewithus.com/herre/nike-free-7-0/ Nike Free 7.0

  5. Many of us are unwilling to sacrifice the look of a heel for the comfort of a flat. air max 2013 http://www.airmaxpascherdesfr.com/ air max 2013

  6. In the past 20 years, with the collapse of the Soviet Union and the deregulation of financial markets, such local and regional networks have exploded into a worldwide criminal fraternity that continues to grow in scope and might.. Nike Air Max TN http://www.darienrotaryclub.com/nike-air-max-tn/ Nike Air Max TN

  7. Mario had been through so much this year so seeing him get that catch and have that big play in the Super Bowl was good. Mens Nike Free TR Fit http://drawingthelight.com/mens-nike-free-tr-fit/ Mens Nike Free TR Fit

  8. Market your Tshirt printing skills to them. page http://www.westwindcopters.com/ page

  9. The golden era of Indian cinema which was considered an extension of Indian art and culture in the international market was largely propelled by the National Film Development Corporation of India (NFDC) up to the early 1980s. ralph lauren skjorte http://www.globalflashpacker.com/women/louis-vuitton-belts/ ralph lauren skjorte

  10. louis vuitton uk outlet real 分享一Oracle脚本 « Oracle小筑

  11. In regards to evaluating the chamois in the store, the only advice I can give is to look at what you already have and compare to that. ralph lauren vest http://www.thatnewsshow.com/ ralph lauren vest

  12. When you hit your goal, congratulations the light is green! You have the option to view your time, NikeFuel you’ve earned, how many steps you’ve taken and how many calories you’ve shed. Nike Free 5.0 http://www.ravewithus.com/herre/nike-free-5-0/ Nike Free 5.0

  13. “On a pure advertising level, [Collins’] only known sponsor, Nike, seems like the perfect company to push the Washington Wizard center’s courageous public stance as an opportunity to further solidify the brand’s recent history of supporting gay rights. nike free run dame http://www.dearmilspouse.com/ nike free run dame

  14. Can the AZY help him? “Our research spanned many key areas,” says Chris Cook, Nike’s senior developer, “such as comfort, cushioning, flexibility, traction, stability and shoe weight.” Impressive stuff. nike store http://drawingthelight.com/ nike store

  15. If Nike published a status update saying “Who your favorite golfer”? and I don Like the Nike page, then there no way that update would appear in my News Feed by itself. Nike Air Max Bw http://www.bestnikeairmaxsale.com/ Nike Air Max Bw

  16. Your text trademark will be evaluated to make sure it doesn’t resemble or sound like any other registered trademarks. nike free run norway http://www.quincetreeinn.com/ nike free run norway

  17. Hence, they create an incredible means of appeal with each one.. Louis Vuitton Outlet http://www.globalflashpacker.com/ Louis Vuitton Outlet

  18. I have been wearing them for a while now and I must say that it was an awesome purchase. ralph lauren shirt http://www.ammijees.com/ ralph lauren shirt

  19. i actually convey my own %anchor% repeatedly consequently they are quite possibly the most decent %anchor% very worth the dollars

  20. adymmxbfkvl
    dymmxbfkvl http://www.g932j070ad7rvm6s4l3xjf0p61tu0k81s.org/
    [url=http://www.g932j070ad7rvm6s4l3xjf0p61tu0k81s.org/]udymmxbfkvl[/url]


香港马会开奖记录|香港马会开奖资料|香港马会开奖现场|香港马会走势图|香港马会开奖结果直播|香港马会n730|