Home >Database >Mysql Tutorial >mysql 批量更新记录

mysql 批量更新记录

WBOY
WBOYOriginal
2016-06-07 14:58:161010browse

replaceinto或者insertinto...onduplicatekeyupdate 可以批量更新 但是replace实际是先delete再insert,自动增长ID会变 所以建议用insertinto...onduplicatekeyupdate 无 INSERT INTO tt(id,age) VALUES (48,1),(50,2),(69,2) ON DUPLICATE KEY UPDATE age=VA

replace into 或者insert into ...on duplicate key update
可以批量更新
但是replace 实际是先delete再insert ,自动增长ID会变
所以建议用insert into ...on duplicate key update
INSERT INTO tt(id,age) VALUES  (48,1),(50,2),(69,2) ON DUPLICATE KEY UPDATE age=VALUES(age);
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:Oracle 还原库Next article:oracle查询表结构