SELECT *   FROM A where A.col1 = 'F&ORG'用shell调sqlplus,要查的是col1值为'F&ORG',但是总是提示输入变量&org

解决方案 »

  1.   

    SQL> insert into test000 values('scott'||chr(38)||'tiger');1 row insertedSQL> commit;Commit completeSQL> select * from test000;username
    ----------------------------------------
    scott&tiger
      

  2.   

    SELECT *   FROM A where A.col1 = 'F' || chr(38) ||'ORG'
      

  3.   

    where A.col1 ='F'||'&'||'ORG'这样行不
      

  4.   

    同样可以的SQL> insert into test000 values('F'||'&'||'ORG');1 row insertedSQL> commit;Commit completeSQL> select * from test000;username
    ----------------------------------------
    scott&tiger
    F&ORG
      

  5.   

    CREATE TABLE t_01(col1 VARCHAR2(20))
    INSERT INTO t_01 VALUES ('F'||'&'||'ORG')
    SELECT * FROM t_01
    SELECT * FROM t_01 WHERE col1='F'||'&'||'ORG'我这里这样倒是可以的
      

  6.   

    SQL> select * from test000 where "username"='scott'||chr(38)||'tiger';username
    ----------------------------------------
    scott&tigerSQL> select * from test000 where "username"='F'||'&'||'ORG';username
    ----------------------------------------
    F&ORG
      

  7.   

    zt回复: 请教:SQL语句中转义符是那个?
    我知道了,在sql*plus中使用转义符'\',要首先修改环境变量 
    set escape on 
    随后就可以使用转义符'\'了,例如 
    SQL>set escape on 
    SQL>select count(*) from employees where name='\[$1'] 
       COUNT(*) 
    ---------- 
              0 
    SQL>select count(*) from employees where name='&1'; 
      
    输入 1 的值:  a 
      
    原值    1: select count(*) from employees where name='&1' 
    新值    1: select count(*) from employees where name='a' 
      
      COUNT(*) 
    --------- 
             0
      

  8.   

    楼上正解SQL> set escape on
    SQL> select 'F&org' from dual;
    Enter value for org: 
    old   1: select 'F&org' from dual
    new   1: select 'F' from dual 
     
    '
    -
    F
     
    SQL> select 'F\&org' from dual;
     
    'F&OR
    -----
    F&org
     
    SQL> 
    谢谢大家回答
    晚上回家结帖