当前位置:网站首页>In the PostgreSQL database, if a field is judged to exist, the update operation is performed. If it does not exist, the insert operation is performed
In the PostgreSQL database, if a field is judged to exist, the update operation is performed. If it does not exist, the insert operation is performed
2022-06-22 06:13:00 【Early summer 0811】
In the actual project development process , I often encounter some kind of business , Determine whether the data exists according to a certain field , If not, proceed insert operation , If it exists, it will be carried out according to this field update operation :
<insert id="insertProject" parameterType="com.lenovo.mcmp.rm.etl.model.param.resourceConfig.CreateResourceConfigParam">
INSERT INTO project(project_code,project_name,start_time,age)
VALUES(#{
project_code},#{
project_name},'2018-01-10 22:00:00',24)
ON conflict(project_code)
DO UPDATE SET project_name= #{
project_name}, start_time='2018-02-22 12:00:00'
</insert>
You can also judge whether this piece of data already exists according to multiple fields :
<insert id="insertProject" parameterType="com.lenovo.mcmp.rm.etl.model.param.resourceConfig.CreateResourceConfigParam">
INSERT INTO project(project_code,project_name,start_time,age)
VALUES(#{
project_code},#{
project_name},'2018-01-10 22:00:00',24)
ON conflict(project_code,age)
DO UPDATE SET project_name= #{
project_name}, start_time='2018-02-22 12:00:00'
</insert>
边栏推荐
- 402 string (Title: Sword finger offer58 ii. left rotation string, 28. implementation of strstr(), 459 Repeated substrings)
- Machine learning concept sorting (no formula)
- R language observation log (part24) -- writexl package
- 【雲計算重點複習】
- 从转载阿里开源项目 Egg.js 技术文档引发的“版权纠纷”,看宽松的 MIT 许可该如何用?
- Configuration files required for SSM integration and error reports caused by common configuration errors
- [NAND file system] UBI introduction
- Le contrôle MFC tabctrl modifie la taille de l'étiquette
- MFC TabCtrl 控件修改標簽尺寸
- 虚职、架空、拖后腿,大厂开源办公室到底什么样?
猜你喜欢

不务正业系列7:老照片去除斑点手法

Single cell thesis records (part9) -- spatial charting of single cell transcriptomes in lectures

单细胞论文记录(part9)--Spatial charting of single-cell transcriptomes in tissues

Single cell thesis record (Part12) -- unsupervised spatial embedded deep representation of spatial transcriptomics

Surfer格网文件裁剪

reduce_sum()中的reduction_indices

活动预告|EdgeX 开发者峰会@南京站 来啦!

Ptrade trading program code - from zero to firm offer 19

小熊派BearPi-HM Micro正式合入OpenHarmony主干

MYSQL牛客刷题
随机推荐
【自己动手写CPU】异常相关指令的实现
TiDB 社区线下交流会,天津 & 石家庄的小伙伴看过来~
Pyg tutorial (7): dissecting neighborhood aggregation
Single cell paper records (part10) -- computational challenges and opportunities in SRT data
[Examen des points clés de l'informatique en nuage]
Unity encrypts ASE game data
【CPU设计实战】数字逻辑电路设计基础(一)
生产者和消费者问题
【云计算重点复习】
基于卫星测深的牙买加沿岸水深测量
Array and foreach traversal in C #
单细胞论文记录(part6)--SpaGE: Spatial Gene Enhancement using scRNA-seq
Use of idea plug-in EASYCODE
上传文件提示 413 Request Entity Too Large 错误
Machine learning concept sorting (no formula)
经验模式分解(EMD)和希尔伯特-黄变换(HHT)
富设备平台突破:基于RK3568的DAYU200进入OpenHarmony 3.1 Release主干
Markdown中插入类图(classDiagram)
Shengxin visualization (Part4) -- correlation diagram
生信文献学习(part1)--PRECISE: a ... approach to transfer predictors of drug response from pre-clinical ...