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

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

问题描述

我想使用replace into语句更新相同模式的表。最后,我需要能够更新可能已更改的值的大表。

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');

我不明白是数据库引擎如何知道什么是重复行,什么是't?这个数据是非常重要的,我不能冒着数据被损坏的风险。是简单的如果列出的所有列都有相同的值,它是一个重复的行?

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"?

我只是想弄清楚一个有效的方法因此我可以在一分钟内更新> 45,000行。

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

推荐答案

文档说:


REPLACE的工作原理INSERT,除了如果表中的旧行与PRIMARY KEY或UNIQUE索引的新行具有相同的值,则在插入新行之前删除旧行。

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天全站免登陆