Home  >  Article  >  Database  >  oracle sqlplus执行sql文件

oracle sqlplus执行sql文件

WBOY
WBOYOriginal
2016-06-07 15:14:092237browse

Oracle 执行外部文件: c:sqlplus user/pwd@db sql@new.sql 执行多个sql文件: 1.把所有的文件都放在同一个目录下,然后在命令行里执行命令: c:dir/b d:/1.sql 会把所有的sql文件名都输出到一个sql文件中。 2.用UltraEdit打开生成的sql文件,alt+C切换到colu

 

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

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn