从PowerShell执行SQL * Plus [英] Execute SQL*Plus from PowerShell

查看:169
本文介绍了从PowerShell执行SQL * Plus的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 C:\temp\SQL\alex.sql C:\temp\alex中有两个文件.ps1

C:\temp\SQL\alex.sql ,就是

select count(*) from user_tables;
quit;

C:\temp\alex.ps1 ,即

$cmd = "sqlplus";
$args = "user/password@server/sid @C:\temp\SQL\alex.sql";
&$cmd $args;

我在命令提示符中尝试过该命令

I tried the command in Command Prompt

sqlplus user / password @ server / sid @C:\temp\SQL\alex.sql 执行得很好!

根本不会执行SQL文件,但是会显示 SQL * Plus帮助

The SQL file is not executed at all, but SQL*Plus help is shown.

我做错了什么?谢谢!

推荐答案

我自己找到了解决方案

我使用了 cmd.exe / c alex.ps1 现在是

$cmd = "cmd.exe";
$args = "/c sqlplus user/password@server/sid @C:\temp\SQL\alex.sql";
&$cmd $args;

希望获得帮助。

这篇关于从PowerShell执行SQL * Plus的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆