mysql主键冲突的解决方案
时间:2023-10-16 18:15:57阅读数:0
mysql主键冲突说明
1、忽略冲突保留原始记录。
2、冲突更新冲突后部分字段变更。
3、冲突替换先删除原始记录,再添加新记录。
4、insert into不考虑冲突效率最高,三种解决冲突的方法都会有效率下降。
需要检索,其中三种效率依次是忽略新数据>更新部分数据>替换全部。
mysql主键冲突的解决实例
create table t_3( username varchar(50) primary key, password char(32) not null, regtime int unsigned not null ) charset utf8; insert into t_3 values('username', 'password', 12345678); # 冲突忽略insert ignore into t_3 values('username','12345678',12345678);
相关文章