当前位置:网站首页>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 = ?边栏推荐
猜你喜欢

Acquisition of mental health service system based on PHP (PHP graduation design)

NSCTF-web题目writeup

(php毕业设计)基于thinkphp5小区物业管理系统

【四】redis持久化(RDB与AOF)

Sales notice: on July 22, the "great heat" will be sold, and the [traditional national wind 24 solar terms] will be sold in summer.

基于php学生学籍管理系统获取(php毕业设计)

进程线程协程的区别

基于php小区疫情出入管理系统(php毕业设计)

文件上传漏洞总结

Prime_Series靶场从探测到提权
随机推荐
JS!!
数据处理之增删改;约束
CMD and NPM basic commands
NSCTF-web题目writeup
分布式锁-数据库实现
反弹shell的N种姿势
数据仓库工具superset安装(完全可用)
Addition, deletion and modification of data processing; constraint
疫情当下,线下文旅受困,看数字藏品能否解围?
记录下在线扩容服务器遇到的问题 NOCHANGE: partition 1 is size 419428319. it cannot be grown
Books - mental models
Sorting and paging, multi table query after class exercise
预告来袭:【豆冰冰】发.售,现.金.抽.奖等你来拿
区分实时数据、离线数据、流式数据以及批量数据的区别
Books - Sun Tzu's art of war
Progressive enhancement and graceful degradation
【四】redis持久化(RDB与AOF)
ModuleNotFoundError: No module named ‘pip‘
Books - investment ideas and Strategies
登录时密码错误次数过多,对该用户进行封禁,