数据过期
我开发了一个应用程序,用户可以在其中创建任务(如议程、ERP 或 CRM) 因此,用户创建了一个任务,并且该任务有一个到期日期。这个想法是在任务到期时删除该条目。
我一直在考虑解决方案,比如有一个计时器等等,但是:
有什么方法或方式来创建过期的数据吗?我的意思是,MySQL、MSSQL(或任何数据库管理器)本身支持这样的东西吗?
我会很高兴有这样的事情:
CREATE TABLE [MyTASK] (expires on mydate action = DELETE){
mydate,
mysomething,
myagain
}
然后,当字段“mydate”过期时,FakeSQL 会删除数据。
I developed an application where the user can create tasks (like a an agenda, ERP or CRM)
So, the user creates a task and that task has an expiration date. The idea is to erase the entry when the task expires.
I've been thinking solutions, like having a timer and so, but:
There is any method or way to create data that expires?? I mean, does MySQL, MSSQL (or any DB Manager) support something like this natively?
I would be great to have something like this:
CREATE TABLE [MyTASK] (expires on mydate action = DELETE){
mydate,
mysomething,
myagain
}
And then, the FakeSQL erases the data when the field "mydate" expires.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
数据不会自行过期。您必须运行某些才能找到并删除它。
MS SQL Server 支持计划作业的概念。因此,您可以指定一个存储过程来删除一周以上的所有内容,并将该作业配置为每晚运行。
Data won't expire itself. You'll have to run something to find and remove it.
MS SQL Server supports the concept of scheduled jobs. So you can specify a stored proc that erases anything over (say) a week old, and configure that job to run every night.
自 5.1 以来,mySQL 似乎有事件调度程序。
mySQL seems to have Event Schedulers since 5.1.
如果存储空间不是问题,那么值得考虑放入一个位字段来将记录标记为已删除,以便在您想要向应用程序添加可以查看所有先前任务的部分时不会丢失任何数据。比如一些管理工具。假设员工正在创建任务,并且任务已过期,并且您不希望普通用户能够修改或访问过期任务,因此您可以在它们过期时“删除”它们。但有一天,大老板过来说他想要一份去年所有任务的清单。这个位字段可能会派上用场。这只是一个想法,也许还有更好的建议
If storage space is not an issue, it's worth a thought about putting in a bit field to mark a record as deleted so that none of your data is lost in case you want to add a part to your application that can look at all previous tasks. Like some administrative tools. Let's say employees are making tasks, and a task has expired and you don't want normal users to be able to modify or access expired tasks, so you "Delete" them when they expire. But one day the big boss comes along and says he wants a list of all tasks in the last year. This bit field could come in handy. It's just a thought and there may be better suggestions out there