PgSQL的with as语法

returning 返回的这一些字段,然后进行汇总为remove_alarms

然后select一下remove_alarms 出来的数据然后保存到tb_alarm_his 里面

复制代码
with remove_alarms as(
delete
from
	tb_alarm
where
	id in ('508') 
	returning 
	0,
	now(),
	'admin',
	alarmadvice,
	alarmadvicecn,
	alarmarisestimestamp,
	alarmclass,
	alarmid,
	alarmlevel,
	alarmname,
	alarmnamecn,
	alarmreason,
	alarmreasoncn,
	alarmsequence,
	currentvalue,
	detail,
	ifservicelive,
	locationinfo1,
	locationinfo2,
	nodeip,
	nodename,
	nodeport,
	podname,
	restartreply,
	servicename,
	sourceservice,
	thresholdvalue,
	tenant,
	confirmstatus,
	confirmer,
	alarmconfirmtimestamp)
insert
	into
	tb_alarm_his (alarmtype,
	alarmrecovertimestamp,
	cleaner,
	alarmadvice,
	alarmadvicecn,
	alarmarisestimestamp,
	alarmclass,
	alarmid,
	alarmlevel,
	alarmname,
	alarmnamecn,
	alarmreason,
	alarmreasoncn,
	alarmsequence,
	currentvalue,
	detail,
	ifservicelive,
	locationinfo1,
	locationinfo2,
	nodeip,
	nodename,
	nodeport,
	podname,
	restartreply,
	servicename,
	sourceservice,
	thresholdvalue,
	tenant,
	confirmstatus,
	confirmer,
	alarmconfirmtimestamp)
select
	*
from
	remove_alarms
相关推荐
xixingzhe216 分钟前
Mysql统计空间增量
数据库·mysql
程序员萌萌1 小时前
Redis的缓存机制和淘汰策略详解
数据库·redis·缓存机制·淘汰策略
不剪发的Tony老师1 小时前
SQLite 3.53.0版本发布,重要更新
数据库·sqlite
Bczheng11 小时前
九.Berkeley DB数据库 序列化和钱包管理(1)
数据库
cozil2 小时前
记录mysql创建数据库未指定字符集引发的问题及解决方法
数据库·mysql
架构师老Y2 小时前
013、数据库性能优化:索引、查询与连接池
数据库·python·oracle·性能优化·架构
AC赳赳老秦2 小时前
OpenClaw数据库高效操作指南:MySQL/PostgreSQL批量处理与数据迁移实战
大数据·数据库·mysql·elasticsearch·postgresql·deepseek·openclaw
一 乐2 小时前
校园线上招聘|基于springboot + vue校园线上招聘系统(源码+数据库+文档)
java·数据库·vue.js·spring boot·论文·毕设·校园线上招聘系统
liliangcsdn2 小时前
如何基于sentence_transformers构建向量计算工具
数据库·人工智能·全文检索
rchmin2 小时前
向量数据库Milvus安装及使用实战经验分享
数据库·milvus