Replace Into Query Syntax(替换为查询语法)
问题描述
我希望能够使用替换为"语句更新相同架构的表.最后,我需要能够使用可能已更改的值更新一个大表.
这是我用来开始的查询:
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.
这篇关于替换为查询语法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:替换为查询语法
基础教程推荐
- Sql Server 字符串到日期的转换 2021-01-01
- SQL Server 中单行 MERGE/upsert 的语法 2021-01-01
- ERROR 2006 (HY000): MySQL 服务器已经消失 2021-01-01
- 在 VB.NET 中更新 SQL Server DateTime 列 2021-01-01
- 如何在 SQL Server 的嵌套过程中处理事务? 2021-01-01
- SQL Server:只有 GROUP BY 中的最后一个条目 2021-01-01
- SQL Server 2016更改对象所有者 2022-01-01
- 无法在 ubuntu 中启动 mysql 服务器 2021-01-01
- 将数据从 MS SQL 迁移到 PostgreSQL? 2022-01-01
- 使用pyodbc“不安全"的Python多处理和数据库访问? 2022-01-01