如何使用 运行 .sql 文件从 powershell 使用 sqlplus

How to run .sql file using sqlplus from powershell

我正在尝试 运行 一个 .sql 文件形式的 powershell 为:-

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

这里TnsAlias指的是我的ORACLE_SID

每当我 运行 这个命令时,我都会得到 sqlplus 的标准使用说明。

谁能帮我解决这个问题。

我正在 运行在 Windows Server 2012 和 Powershell 4.0 版上使用它,如果有帮助的话。

这对我有用:

PS M:\> sqlplus scott/tiger@kc11g "@m:\dbscript.sql"

SQL*Plus: Release 11.2.0.1.0 Production on ╚et Kol 16 07:59:25 2018

Copyright (c) 1982, 2010, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options


    DEPTNO DNAME          LOC
---------- -------------- -------------
        10 ACCOUNTING     NEW YORK
        20 RESEARCH       DALLAS
        30 SALES          CHICAGO
        40 OPERATIONS     BOSTON

SQL>