当前位置:网站首页>Two methods of covering duplicate records in tables in MySQL
Two methods of covering duplicate records in tables in MySQL
2022-07-28 06:01:00 【Programmer awei】
replace into The way
Prerequisite
There must be a primary key or unique index in the table .
principle
Find data with the same primary key according to the primary key or unique index , Then delete the original data , Add new data .
If there is no same primary key or unique index in the table , It's equivalent to insert into.
Use cases
# topic、partition、groupid It's the primary key
replace into t_offset (`topic`, `partition`, `groupid`, `offset`) values(?,?,?,?)")ON DUPLICATE KEY UPDATE The way
Prerequisite
There must be a primary key or unique index in the table .
principle
Find data with the same primary key according to the primary key or unique index , And then execute update update operation .
If there is no same primary key or unique index in the table , It's equivalent to insert into.
Use cases
# userid It's the primary key
insert into black_list(userid) value (?)
on DUPLICATE KEY
UPDATE userid = ?边栏推荐
- MarsNFT :个人如何发行数字藏品?
- The combination of cultural tourism and digital collections has a significant effect, but how to support users' continuous purchasing power
- 记录下在线扩容服务器遇到的问题 NOCHANGE: partition 1 is size 419428319. it cannot be grown
- 【四】redis持久化(RDB与AOF)
- Variables, process control and cursors
- 记某淘宝客软件分析拿库思路
- Progressive enhancement and graceful degradation
- Wechat official account - authorized login
- Beginner mobile terminal
- 服务可靠性保障-watchdog
猜你喜欢

记录下在线扩容服务器遇到的问题 NOCHANGE: partition 1 is size 419428319. it cannot be grown
Installation and use of sqoop

(php毕业设计)基于php校园网络报修管理系统获取

浅谈数字藏品与实体如何相互赋能

Books - the art of lucid thinking

Books - mob

CVE_2017_11882漏洞复现(Metasploit开启NT远程桌面添加账户)

On how digital collections and entities can empower each other

(php毕业设计)基于php学生日常行为管理系统获取

极客大挑战2019-SQL注入五题PW
随机推荐
数藏如何实现WEB3.0社交
分布式锁-Redis实现
JS simple publish and subscribe class
mysql分页出现问题
cmd和npm基础命令
Digital collections strengthen reality with emptiness, enabling the development of the real economy
记某淘宝客软件分析拿库思路
第七章 单行函数
数字藏品“大乱斗”,千亿市场变局将至?
【四】redis持久化(RDB与AOF)
DataX installation and use
Linux(centOs7) 下安装redis
Mysql的两种覆盖表中重复记录的方法
trino函数随记
单行函数,聚合函数课后练习
(php毕业设计)基于php在线旅游网站管理系统获取
Sorting and paging, multi table query after class exercise
【一】redis简介
【七】redis缓存与数据库数据一致性
1: Enable slow query log and find slow SQL