zoukankan      html  css  js  c++  java
  • 基于Linux的oracle数据库管理 part4( shell管理 上 )

    主要内容

    1. shell 基础补充

    2. shell脚本与 SQL*PLUS

    shell 基础补充

      - $(()) 中内容被看做是算术表达式, 其中的变量有没有”$”都可以, 例如 result = $((var1 + var2))   echo $((var1++))

      - if condition ; then

        elif condition ; then

        else

        fi   注意: 如果 then 另起一行写的话, 就可以不用 ; 号

       - 条件测试, test, [] [[]] (()), 其中 test 等价于 [], 当使用“>”或”<”用于比较字符串的要用 [[]] 双括号

       - for arg in list; do

             command

         done

         for ((a=1; a<=100; a++))

         do

             sum = sum + 1

         done

       - while condition ; do

             command

         done

      

    shell 脚本与 SQL*PLUS

      - 在shell脚本中调用 sql*plus, 例如: cat sqlplus.sh

        image
      - 把 sql 查询结果赋给 shell 变量
        1. 查询结果直接赋值给变量
        image
        2.  在使用exit命令退出sql*plus时, 把sql查询结果作为附加退出状态值, 这个值默认存入$?系统变量, 使用 col new_value使得SQL语句可以使用变量       
            在 sql*plus 中使用 
    column
     row_name 
    new_value
     variable_name
        image
      - 把shell程序参数传递给sql命令
        使用 $1 将参数传递给sql, 

        image

      - shell 中常用的 sql*plus 环境设置

        -silent, 会将sql提示符及 sqlplus 信息全部不显示, 交互式不要使用

        set pagesize 0

        set feedback off

        set heading off

        set verify off 在 sql 脚本中使用了变量, 在执行这个sql脚本时, 默认会显示变量值的确认信息, 如果不需要这种信息, 就设置off

        set echo off  不显示脚本内容

        set termout off 不显示执行结果
      - 调用 sql * plus 口令安全

        将密码保存在变量内, 执行脚本时, 给予变量形参.

        从文件导入口令, echo ‘tiger’ >scott.pw, chmod g-rwx, o-rwx scott.pw, 设置文件属性, 执行脚本

        image

       

  • 相关阅读:
    hibernate_0100_HelloWorld
    MYSQL子查询的五种形式
    JSF是什么?它与Struts是什么关系?
    nop指令的作用
    htmlparser实现从网页上抓取数据(收集)
    The Struts dispatcher cannot be found. This is usually caused by using Struts tags without the associated filter. Struts tags are only usable when the
    FCKeditor 在JSP上的完全安装
    Java遍历文件夹的2种方法
    充电电池和充电时间说明
    吃知了有什么好处
  • 原文地址:https://www.cnblogs.com/moveofgod/p/3412774.html
Copyright © 2011-2022 走看看