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
相关推荐
WeiQ_2 小时前
解决phpstudy 8.x软件中php8.2.9没有redis扩展的问题
数据库·redis·缓存
DashVector6 小时前
向量检索服务 DashVector产品计费
数据库·数据仓库·人工智能·算法·向量检索
KYGALYX7 小时前
在Linux中备份msyql数据库和表的详细操作
linux·运维·数据库
檀越剑指大厂7 小时前
金仓KReplay:定义数据库平滑迁移新标准
数据库
努力成为一个程序猿.8 小时前
【Flink】FlinkSQL-动态表和持续查询概念
大数据·数据库·flink
毕设十刻8 小时前
基于Vue的学分预警系统98k51(程序 + 源码 + 数据库 + 调试部署 + 开发环境配置),配套论文文档字数达万字以上,文末可获取,系统界面展示置于文末
前端·数据库·vue.js
liliangcsdn9 小时前
如何利用约束提示优化LLM在问题转sql的一致性
数据库·sql
Java爱好狂.10 小时前
分布式ID|从源码角度深度解析美团Leaf双Buffer优化方案
java·数据库·分布式·分布式id·es·java面试·java程序员
Elastic 中国社区官方博客10 小时前
通过混合搜索重排序提升多语言嵌入模型的相关性
大数据·数据库·人工智能·elasticsearch·搜索引擎·ai·全文检索
倔强的石头10611 小时前
KingbaseES:从兼容到超越,详解超越MySQL的权限隔离与安全增强
数据库·mysql·安全·金仓数据库