MYSQL避免重复插入记录的三种方法


 

http://dev.mysql.com/doc/refman/5.1/zh/sql-syntax.html#replace

http://dev.mysql.com/doc/refman/5.1/zh/sql-syntax.html#insert

特别说明:在MYSQL中UNIQUE 索引将会对null字段失效,也就是说(a字段上建立唯一索引):

  1. insert into test(a) values(null)
  2. insert into test(a) values(null)

是可以重复插入的(联合唯一索引也一样)。