Oracle (sqlplus) 如何使用另一个硬盘上文件的绝对路径?

How to use the absolute path of a file on another hard drive with Oracle (sqlplus)?

我很惊讶我在任何地方都没有找到任何关于此的信息,但是我如何使用文件的绝对路径使用 sqlplus 执行文件?网上说

sqlplus databaseURL @sqlFile

如果我将它用作相对文件并在同一目录中包含 SQL 文件,则此方法有效。但是在“@”之后使用路径是行不通的,当我 运行 命令时它说 "file does not exist" 。该文件肯定在指定路径中,我在 Windows.

我该如何进行这项工作?

编辑:相对路径示例:

sqlplus -l user/pw@localhost:1521/service @test.sql;

绝对路径示例

sqlplus -l user/pw@localhost:1521/service @D:/folder/test.sql;

还有另一种可能性:设置 SQLPATH 环境变量以指定 SQL*Plus 应该查找 SQL 文件的位置:

Doc. says

The SQLPATH registry entry specifies the location of SQL scripts. SQL*Plus searches for SQL scripts in the current directory and then in the directories specified by the SQLPATH registry entry, and in the subdirectories of SQLPATH directories.

The HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\HOME0 registry subkey (or the HOMEn directory for the associated ORACLE_HOME) contains the SQLPATH registry entry. SQLPATH is created with a default value of ORACLE_HOME\DBS. You can specify any directories on any drive as valid values for SQLPATH.

When setting the SQLPATH registry entry, you can concatenate directories with a semicolon (;). For example:

c:\oracle\ora12\database;c:\oracle\ora12\dbs

See the Registry Editor's help system for instructions on how to edit the SQLPATH registry entry.

所以为了澄清我的问题是什么,它实际上只是在文件本身中。我在 SQL 文件的末尾使用“\”而不是“/”。在我改变它之后,它对我有用。我的命令最后看起来像这样:

sqlplus -l user/pw@localhost:1521/service @D:\folder\test.sql;