gpt4 book ai didi

mysql - 替换成查询语法

转载 作者:IT老高 更新时间:2023-10-28 12:58:37 24 4
gpt4 key购买 nike

我希望能够使用“replace into”语句更新具有相同架构的表。最后,我需要能够使用可能已更改的值更新一个大表。

这是我用来开始的查询:

REPLACE INTO table_name
(visual, inspection_status, inspector_name, gelpak_name, gelpak_location),
VALUES (3, 'Partially Inspected', 'Me', 'GP1234', 'A01');

我不明白的是数据库引擎如何知道什么是重复行,什么不是?这些数据非常重要,我不能冒数据被损坏的风险。是否像“如果列出的所有列都具有相同的值,则它是重复行”那么简单?

我只是想找出一种有效的方法来做到这一点,这样我就可以在一分钟内更新超过 45,000 行。

最佳答案

作为 documentation说:

REPLACE works exactly like INSERT, except that if an old row in the table has the same value as a new row for a PRIMARY KEY or a UNIQUE index, the old row is deleted before the new row is inserted.

关于mysql - 替换成查询语法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19820724/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com