4 ms·
According to the docs, a delete+insert is exactly what is does: http://dev.mysql.com/doc/refman/5.1/en/replace.html http://dev.mysql.com/doc/refman/5.1/en/repla
by 0x0 13y ago
According to the docs, a delete+insert is exactly what is does: http://dev.mysql.com/doc/refman/5.1/en/replace.html http://dev.mysql.com/doc/refman/5.1/en/replace.html
- Udo 13y agoYou're right. Sorry.
- martin-adams 13y agoLooks like you have to be careful of any ON DELETE CASCADE constraints as it could delete more than you bargain for.
- drawkbox 13y agoI agree. DELETING when you want to do an UPDATE or INSERT just seems wrong on all levels. DELETING is dangerous and I tend to prefer slightly slower performance of UPSERT with UPDATE/INSERT than involving a delete in the operation.
- lazyjones 13y agoThat's what MySQL's REPLACE does, but not what "upsert" means: http://en.wiktionary.org/wiki/upsert http://en.wiktionary.org/wiki/upsert In presence of foreign key constraints for example, DELETE+INSERT might break/fail when UPDATE+INSERT will not. Also, the performance characteristics might be different.