当前位置:网站首页>1. PostgreSQL根据动态表名查询近24小时数据
1. PostgreSQL根据动态表名查询近24小时数据
2022-07-17 02:00:00 【CAFEBABE 34】
一、 查询近24小时数据
- 调用方法
public void findData(String tableName) {
// tableName 需要进行 双引号的拼接 否则会出现转义
tableName = "\"" + "\"";
List<Map<String, String>> list = testMapper.checkData(tableName);
}
- 需要执行的sql
<!--statementType="STATEMENT" (非预编译) -->
<select id="checkData" resultType="java.util.Map" statementType="STATEMENT">
select *
# 因为开启了非预编译所以使用${} 表名的拼接
from ${tableName}
where "time" :: TIMESTAMP >= ( to_char( now( ) :: TIMESTAMP, 'yyyy-MM-dd HH24:00:00' ) :: TIMESTAMP - INTERVAL '24 hour' )
AND "time" :: TIMESTAMP < ( to_char( now( ) :: TIMESTAMP, 'yyyy-MM-dd HH24:00:00' ) :: TIMESTAMP )
</select>
二、根据动态表白删除24小时之前的数据
- 调用函数
public void deleteByName(String name) {
test.deledeByName("\"" + name + "\"");
}
- sql
<!--删除24小时之前的数据-->
<delete id="deledeByName" statementType="STATEMENT">
delete from ${name}
where "time" :: TIMESTAMP < ( to_char( now( ) :: TIMESTAMP, 'yyyy-MM-dd HH24:00:00' ) :: TIMESTAMP - INTERVAL '24 hour')
</delete>
边栏推荐
- Gnome boxes virtual machine creation and installation
- Browser cannot open tensorboard
- central limit theorem
- Nim博奔问题
- Latex environment configuration based on pandoc and vscode
- MySQL master-slave setup
- Leetcode: subsequence problem in dynamic programming
- [2016 CCPC Hangzhou j] just a math problem (Mobius inversion)
- VGG (Visual Geometry Group)
- Basic IDL content of note 1: common data types_ Create array_ Type conversion_ Print output_ Basic operation_ Relational operation
猜你喜欢

上班摸鱼打卡模拟器微信小程序源码
![Leetcode: dynamic programming [basic problem solving]](/img/fc/0ff622576a47868f8ecf70116ea2f2.png)
Leetcode: dynamic programming [basic problem solving]

XX City high school network topology overall planning configuration

Thinkphp5.0模型操作使用page进行分页

Underline shortcut

GoogLeNet

HRNet

論文閱讀:U-Net++: Redesigning Skip Connections to Exploit Multiscale Features in Image Segmentation

Edge detection method -- first order edge detection

数学建模学习(67):XGBoost分类模型详细入门案例教程
随机推荐
Underline shortcut
模块(block、module)的介绍
leetcode:50. Pow(x, n)
Note: light source selection and Application
leetcode162. 寻找峰值
Introduction of modules (block, module)
Gdb+vscode for debugging 8 - use core to analyze dead cycles, deadlocks, and segment errors
神器网站目录,全都是刚需好用的网站
KubeCon + CloudNativeCon Europe 2022
web语义化(强调标签-em-斜体)(重点强调标签-strong-粗体)(自定义列表:dl、dt、dd)
Receiver operating curve
上班摸鱼打卡模拟器微信小程序源码
Installing PWA application in Google Chrome browser will display more description information
oracle 关闭回收站
[C语言勘误]数组长度的函数内获取方式错误
如何将Excel中的数据粘贴到cxGrid中
Qt OpenGL 通过鼠标和键盘移动三维物体(设置相机)
Frequency school and Bayes school
动态管理内存的通讯录实现
论文阅读:U-Net++: Redesigning Skip Connections to Exploit Multiscale Features in Image Segmentation