默认情况下,在sqlplus中通过start或者@调用脚本时,只会在系统当前工作路径中搜索脚本,例如下面的例子中,必须将脚本t.sql放到d:\目录下,否则将报错。
D:\>sqlplus ning/ning@orcl
SQL*Plus: Release 10.2.0.3.0 – Production on Tue Jul 24 13:35:21 2007
Copyright (c) 1982, 2006, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 – Production
With the Partitioning, OLAP and Data Mining options
NING@orcl>@t
I
———-
1
NING@orcl>@tt
SP2-0310: unable to open file “tt.sql”
如果要将脚本放置到其他目录,并且可以在sqlplus中直接调用,而不用输入绝对路径,则可以通过设置环境变量(或者注册表值)SQLPATH(Unix/Linux中也可以设置ORACLE_PATH环境变量)来实现。
D:\>cd soft
D:\soft>set SQLPATH=D:\
D:\soft>sqlplus ning/ning@orcl
SQL*Plus: Release 10.2.0.3.0 – Production on Tue Jul 24 13:39:05 2007
Copyright (c) 1982, 2006, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 – Production
With the Partitioning, OLAP and Data Mining options
NING@orcl>@t
I
———-
1

补充一下,先当前目录,再SQLPATH目录
[...] sqlplus : . :NinGoo | … , sqlplus , , ( )SQLPATH(Unix/Linux … Read This [...]
[...] NinGoo@Net — sqlplus : , sqlplus , , ( … Oracle11g SQLPLUS Blob . Oracle11g bug. Redhat Entrerprise Linux 5 Oracle11g … [...]