mysql: insert ignore、insert、replace

指令               已存在     不存在      舉例
insert              報錯         插入         insert into names(name, age) values(“小明”, 23);
insert ignore   忽略         插入         insert ignore into names(name, age) values(“小明”, 24);
replace           替換         插入         replace into names(name, age) values(“小明”, 25);

表要求:有PrimaryKey,或者unique索引
結果:表id都會自增

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章