我想往oracle表中插入数据,有个问题困扰我好久了,希望得到大虾的帮助!!!以下是问题描述:
我想做用SQL语句判断  a表中  是否有该数据,如果没有就增加,如果有就不增加。

解决方案 »

  1.   

    insert into a
    select 'xx','xx','xx' from dual
    where not exists(
      select 1 from a where a.xx='xx')
      

  2.   

    oracle 用plsql实现数据,如果没有就增加,如果有就不增加
      

  3.   


    declare
    iCount number;
    begin
      select count(1) into iCount from t1;
      if iCount=0 then 
        insert into t1 select null from dual;
      end if;
        
    end;
      

  4.   


    2楼的sql语句已经帮你实现了啊
      

  5.   

    根据二楼的回答,楼主的问题答案应该是:
    insert into a
    select '张三',30 from dual
    where not exists(
    select name from a where name='张三'
    )
      

  6.   

      不好意思,误会 2楼的了,是的,可以增加成功,开始我把from dual  这个表名也换成A表了,非常感谢各位对我指导。