替换为查询语法 [英] Replace Into Query Syntax

查看:30
本文介绍了替换为查询语法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够使用替换为"语句更新相同架构的表.最后,我需要能够使用可能已更改的值更新一个大表.

这是我用来开始的查询:

REPLACE INTO table_name(视觉,检查状态,检查员名称,gelpak_name,gelpak_location),值(3,部分检查",我",GP1234",A01");

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

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

解决方案

作为文档

a> 说:

<块引用>

REPLACE 的工作方式与 INSERT 完全相同,但如果表中的旧行与 PRIMARY KEY 或 UNIQUE 索引的新行具有相同的值,则在插入新行之前删除旧行.

I want to be able to update a table of the same schema using a "replace into" statement. In the end, I need to be able to update a large table with values that may have changed.

Here is the query I am using to start off:

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

What I don't understand is how does the database engine know what is a duplicate row and what isn't? This data is extremely important and I can't risk the data being corrupted. Is it as simple as "if all columns listed have the same value, it is a duplicate row"?

I am just trying to figure out an efficient way of doing this so I can update > 45,000 rows in under a minute.

解决方案

As the documentation says:

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.

这篇关于替换为查询语法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆