下面这种写法,真的能保证t表的id是唯一的吗?设为unique肯定可以,我只是想和各位大能探讨保证唯一的方法
insert into t(id)
  select :v_id from dual 
  where not exists(select id from t where id = :v_id)
谢谢!

解决方案 »

  1.   


    序列肯定也是可以的,我只是想探讨下,上面的SQL可不可以保证唯一???
      

  2.   


    序列肯定也是可以的,我只是想探讨下,上面的SQL可不可以保证唯一???可以的
      

  3.   


    序列肯定也是可以的,我只是想探讨下,上面的SQL可不可以保证唯一???可以的答案是不可以的,我测了下
      

  4.   


    序列肯定也是可以的,我只是想探讨下,上面的SQL可不可以保证唯一???可以的答案是不可以的,我测了下贴代码,你可以在t表插入相同的记录?
    insert into t(id)   select :v_id from dual    where not exists(select id from t where id = :v_id) 
      

  5.   

    执行insert之前,上lock table!
      

  6.   

    .....就算串也没所谓多少个null都插得进