日期:2014-05-17  浏览次数:20889 次

在sqlplus中执行含有&字符的sql文件的问题。请进
我有一个sql文件:test.sql   内容如下:

insert   into   test   valuse( 'C&Shell   is   good. ');

当我在sqlplus   上执行这个文件时,提示我输入Shell的值。但实际上我并不想输入Shell的值,而是我想把整个当成一个字符串并不是要输入值。&字符由于实际业务需求必须要,我应该怎么解决?

------解决方案--------------------
insert into test values ( 'C\&Shell is good. ');

------解决方案--------------------
set define off
------解决方案--------------------
方法很多
insert into test values ( 'C '|| '& '|| 'Shell is good. ');

或者
set define off
insert into test values ( 'C&Shell is good. ');

或者
set define on
set esc on
insert into test values ( 'C\&Shell is good. ');
set esc off

例如

SQL> select * from test;

no rows selected

SQL> insert into test values ( 'C '|| '& '|| 'Shell is good. ');

1 row created.

SQL>
SQL> set define off
SQL> insert into test values ( 'C&Shell is good. ');

1 row created.

SQL>
SQL> set define on
SQL> set esc on
SQL> insert into test values ( 'C\&Shell is good. ');

1 row created.

SQL> set esc off
SQL> select * from test;

ID
-----------------------
C&Shell is good.
C&Shell is good.
C&Shell is good.

SQL>
------解决方案--------------------
set define off