【问题标题】:How to run an SQL file with sqlplus in Powershell ISE如何在 Powershell ISE 中使用 sqlplus 运行 SQL 文件
【发布时间】:2020-02-13 12:05:05
【问题描述】:

我想用 sqlplus 执行一个 SQL 文件,但是当我尝试在 Powershell ISE 中执行时,结果显示如何使用 sqlplus。 The result I get

我在 ISE 的示例中使用的代码是:

sqlplus "username/password@database @C:Path\To\file.sql"

但是当我在 CMD 或常规 Powershell 中运行此代码时,它可以正常工作。结果只是一些虚拟的Select 1 from dual

我试图将路径放在一个单独的 qoute( ' ) 中,有和没有 @ (引号内部和外部),但没有任何效果。在谷歌搜索这个问题时,我也没有找到太多。

我也尝试过连接,它可以正常工作,但连接后我无法输入任何内容。 Result with just the connect

【问题讨论】:

    标签: sql oracle powershell sqlplus


    【解决方案1】:

    因为你做错了

    真正的语法是

    sqlplus username/password@TnsAlias 'c:\path\to\DBscript.sql' | out-file 'c:\temp\sql- output.txt'
    

    我认为你 (') 早点使用。

    或者在没有outfile的情况下试试这个

    $output = sqlplus username/password@TnsAlias 'c:\path\to\DBscript.sql'
    

    存储在变量中

    【讨论】:

    • 我都试过了,my code 第一个是原始的。但是当我检查 txt 文件时,我在 sqlplus 上得到相同的结果只是一些 genreal info
    • 在 Idrish 的 anwser 的帮助下弄清楚了,我只需要删除原始代码中的引号就可以了。花了我很长时间......
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-13
    • 2019-02-26
    • 2011-06-06
    • 1970-01-01
    • 2018-02-18
    • 2022-01-08
    相关资源
    最近更新 更多