RT

解决方案 »

  1.   

    select count(*) from table where id = ‘你要插入的数据'
    如果不存在则 insert
    否这不执行insert
      

  2.   

    谢谢,能写成一条sql语句吗?
      

  3.   

    IF not EXISTS(select 1 from table where id = ‘你要插入的主键')
     insert into tb(.....) values(.....)
      

  4.   

    insert into student(id)
    (select '1' as id from dual where not exists(select * from student where id = '1'))
    表 student
    主键 id
    插入 1
      

  5.   

    可以创建序列sequence,每次插入的时候从序列来获得他的主键值。