<bdo id='BEN5u'></bdo><ul id='BEN5u'></ul>
  • <small id='BEN5u'></small><noframes id='BEN5u'>

    <i id='BEN5u'><tr id='BEN5u'><dt id='BEN5u'><q id='BEN5u'><span id='BEN5u'><b id='BEN5u'><form id='BEN5u'><ins id='BEN5u'></ins><ul id='BEN5u'></ul><sub id='BEN5u'></sub></form><legend id='BEN5u'></legend><bdo id='BEN5u'><pre id='BEN5u'><center id='BEN5u'></center></pre></bdo></b><th id='BEN5u'></th></span></q></dt></tr></i><div id='BEN5u'><tfoot id='BEN5u'></tfoot><dl id='BEN5u'><fieldset id='BEN5u'></fieldset></dl></div>
    <legend id='BEN5u'><style id='BEN5u'><dir id='BEN5u'><q id='BEN5u'></q></dir></style></legend><tfoot id='BEN5u'></tfoot>

        如何从 bash 脚本中执行 SQL?

        How do you execute SQL from within a bash script?(如何从 bash 脚本中执行 SQL?)

          <tfoot id='QQyWu'></tfoot>

            <i id='QQyWu'><tr id='QQyWu'><dt id='QQyWu'><q id='QQyWu'><span id='QQyWu'><b id='QQyWu'><form id='QQyWu'><ins id='QQyWu'></ins><ul id='QQyWu'></ul><sub id='QQyWu'></sub></form><legend id='QQyWu'></legend><bdo id='QQyWu'><pre id='QQyWu'><center id='QQyWu'></center></pre></bdo></b><th id='QQyWu'></th></span></q></dt></tr></i><div id='QQyWu'><tfoot id='QQyWu'></tfoot><dl id='QQyWu'><fieldset id='QQyWu'></fieldset></dl></div>

                <tbody id='QQyWu'></tbody>

              <legend id='QQyWu'><style id='QQyWu'><dir id='QQyWu'><q id='QQyWu'></q></dir></style></legend>

              <small id='QQyWu'></small><noframes id='QQyWu'>

                <bdo id='QQyWu'></bdo><ul id='QQyWu'></ul>
                • 本文介绍了如何从 bash 脚本中执行 SQL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一些试图自动化的 SQL 脚本.过去,我使用过 SQL*Plus,并从 bash 脚本手动调用了 sqlplus 二进制文件.

                  I have some SQL scripts that I'm trying to automate. In the past I have used SQL*Plus, and called the sqlplus binary manually, from a bash script.

                  但是,我试图弄清楚是否有办法连接到数据库,并从 bash 脚本内部调用脚本......这样我就可以插入 date 并制作查询相对于过去的特定天数运行.

                  However, I'm trying to figure out if there's a way to connect to the DB, and call the script from inside of the bash script... so that I can insert date and make the queries run relative to a certain number of days in the past.

                  推荐答案

                  我有点困惑.您应该能够从 bash 脚本中调用 sqlplus.这可能就是你在第一条语句中所做的

                  I'm slightly confused. You should be able to call sqlplus from within the bash script. This may be what you were doing with your first statement

                  尝试在您的 bash 脚本中执行以下操作:

                  Try Executing the following within your bash script:

                  #!/bin/bash          
                  echo Start Executing SQL commands
                  sqlplus <user>/<password> @file-with-sql-1.sql
                  sqlplus <user>/<password> @file-with-sql-2.sql
                  

                  如果您希望能够将数据传递到您的脚本中,您可以通过 SQLPlus 通过将参数传递到脚本中来实现:

                  If you want to be able to pass data into your scripts you can do it via SQLPlus by passing arguments into the script:

                  file-with-sql-1.sql

                   select * from users where username='&1';
                  

                  然后改bash脚本调用sqlplus传入值

                  Then change the bash script to call sqlplus passing in the value

                  #!/bin/bash
                  
                  MY_USER=bob
                  sqlplus <user>/<password> @file-with-sql-1.sql $MY_USER
                  

                  这篇关于如何从 bash 脚本中执行 SQL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How to redirect the output of DBMS_OUTPUT.PUT_LINE to a file?(如何将 DBMS_OUTPUT.PUT_LINE 的输出重定向到文件?)
                  How do I get column datatype in Oracle with PL-SQL with low privileges?(如何使用低权限的 PL-SQL 在 Oracle 中获取列数据类型?)
                  Get a list of all functions and procedures in an Oracle database(获取 Oracle 数据库中所有函数和过程的列表)
                  Why cannot I create triggers on objects owned by SYS?(为什么我不能在 SYS 拥有的对象上创建触发器?)
                  Returning result even for elements in IN list that don#39;t exist in table(即使对于表中不存在的 IN 列表中的元素也返回结果)
                  Reset Sequence in oracle 11g(oracle 11g 中的重置序列)
                    • <legend id='Q8OD7'><style id='Q8OD7'><dir id='Q8OD7'><q id='Q8OD7'></q></dir></style></legend>
                    • <tfoot id='Q8OD7'></tfoot>
                    • <i id='Q8OD7'><tr id='Q8OD7'><dt id='Q8OD7'><q id='Q8OD7'><span id='Q8OD7'><b id='Q8OD7'><form id='Q8OD7'><ins id='Q8OD7'></ins><ul id='Q8OD7'></ul><sub id='Q8OD7'></sub></form><legend id='Q8OD7'></legend><bdo id='Q8OD7'><pre id='Q8OD7'><center id='Q8OD7'></center></pre></bdo></b><th id='Q8OD7'></th></span></q></dt></tr></i><div id='Q8OD7'><tfoot id='Q8OD7'></tfoot><dl id='Q8OD7'><fieldset id='Q8OD7'></fieldset></dl></div>
                        <tbody id='Q8OD7'></tbody>

                      <small id='Q8OD7'></small><noframes id='Q8OD7'>

                            <bdo id='Q8OD7'></bdo><ul id='Q8OD7'></ul>