首页 > 解决方案 > 如何使用 powershell 中的 sqlplus 运行 .sql 文件

问题描述

我正在尝试将 .sql 文件从 powershell 运行为:-

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

这里的 TnsAlias 指的是我的 ORACLE_SID

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

有人可以帮我解决这个问题。

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

标签: oraclepowershellsqlplus

解决方案


这对我有用:

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>

推荐阅读