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