MySQL赋予行终身 [英] MySQL give rows a lifetime

查看:56
本文介绍了MySQL赋予行终身的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何创建行的生存期,以便在特定时间(例如2周)后行会自动删除?任何信息都很棒.

How can I create a lifetime of a row so after a specific time say 2 weeks the row will automatically erase? Any info would be great.

推荐答案

RDBMS通常不允许行自动自毁.这对企业不利.

RDBMS don't generally allow rows to automatically self destruct. It's bad for business.

更严重的是,一些想法取决于您的确切需求

More seriously, some ideas, depending on your exact needs

  • 运行计划的作业以运行DELETE来删除基于某些日期/时间列的行
  • (更复杂的想法)使用带有滑动窗口的分区表将较旧的行移动到另一个分区
  • 使用视图仅显示少于2周的行
  • run a scheduled job to run a DELETE to remove rows based on some date/time column
  • (more complex idea) use a partitioned table with a sliding window to move older rows to another partition
  • use a view to only show rows less than 2 weeks old

这篇关于MySQL赋予行终身的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆