zoukankan      html  css  js  c++  java
  • perl管理oracle实例

    -- perl oracle管理
    #!/usr/bin/perl
    use strict;
    use warnings;

    my $ORACLE_HOME = '/u01/oracle';
    my $ORACLE_SID = 'orcl';
    my $PATH = $ENV{PATH};

    my $user;
    my $passwd;
    my $ora_conn;

    $ENV{ORACLE_HOME} = $ORACLE_HOME;
    $ENV{ORACLE_SID} = $ORACLE_SID;
    $ENV{PATH} = "$ORACLE_HOME/bin:$PATH";
    $EVN{LD_LIBRARY_PATH} = "$ORACLE_HOME/lib:$LIBPATH";

    $user = "u01";
    $passwd = "u01";
    $ora_conn = "$user/$passwd\@morewood";

    system("./drop_object.sh $ora_conn $user > /dev/null 2>\&1 &");
    print "......Delete Done!......\n";

    sleep(2);

    system("imp $user/$passwd file=$user.dmp full=y buffer=10485760 ignore=Y log=$user.log &");
    print "......Import Done!......\n";

    exit


     --------------------------------------------------------

    #!/bin/sh
    #name drop_object.sh
    sqlplus -s << EOF
    $1
    set pages 0;
    set term off;
    set feedback off;
    spool /tmp/dropobj.$2.sql
    select 'alter session set recyclebin=off;' from dual;
    select 'drop ' || object_type || ' ' ||  object_name || ';' from user_objects where object_type = 'TABLE';
    select 'drop ' || object_type || ' ' || object_name || ';' from user_objects where object_type ='INDEX';
    spool off
    @/tmp/dropobj.$2.sql
    exit
    EOF
    #
    exit

  • 相关阅读:
    离线安装 Cloudera Manager 5 和 CDH5.10
    Sersync+Rsync实现触发式文件同步
    Azkaban3.x集群部署(multiple executor mode)
    内置函数
    递归
    嵌套函数,匿名函数,高阶函数
    局部变量,全局变量,作用域
    函数的介绍
    文件处理
    第二模块-三元运算
  • 原文地址:https://www.cnblogs.com/alang85/p/2552921.html
Copyright © 2011-2022 走看看