用replace行吗?

解决方案 »

  1.   

    用substr函数去截取第一个字符。
    declare
       v_tmp varchar2(2);
    begin
       select substr('PS',1,1) into v_tmp from dual;
       if v_tmp = 'P' then
         dbms_output.put_line('开头是P字母');
       else
         dbms_output.put_line('开头不是P字母');
       end id;
    end;
      

  2.   

    如果你是在查询的时候判断的话,那么可以这样写.select e.ename, e.sal from emp e where e.ename like 'P%';
    或者
    select e.ename, e.sal from emp e where lower(substr(e.ename,1,1))=lower('P');这样会查出名字是以P开头的信息.
      

  3.   


    select decode(substr('pma',1,1),'p','p','不p') c1,
           decode(substr('zuoma',1,1),'p','p','不p') c2
    from dual     c1    c2
    -------------------------
    1 p 不p
      

  4.   

    substr 或者 like 都可以,没必要正则,复杂了。