Oracle 执行sql文件

原文地址:http://blog.csdn.net/jgchenhunter/archive/2009/01/13/3765526.aspx

Oracle执行外部文件:

c:>sqlplus user/pwd@db

sql>@new.sql

执行多个sql文件:

1.把所有的文件都放在同一个目录下,然后在命令行里执行命令:
c:>dir/b > d:\1.sql
会把所有的sql文件名都输出到一个sql文件中。
2.用UltraEdit打开生成的sql文件,alt+C切换到column mode,给所有的行前都添加一个“@”,保存。
3.在sqlplus中执行“@d:\1.sql”

如何避免'&'字符:

sql中&可以传递参数,但有时需要插入'&',例:

SQL> select '&hello' v from dual;
输入 hello 的值: hello
原值 1: select '&hello' v from dual
新值 1: select 'hello' v from dual

v
-----
hello

可以使用如下方法避免:

A:

SQL> select chr(38) || 'hello' v from dual;

V
------
&hello

B:

SQL> set define off
SQL> select '&hello' v from dual;

V
------
&hello

猜你喜欢

转载自javasam.iteye.com/blog/1839719