超过1000条记录后删除旧记录 [英] delete old record after exceeding 1000 records

查看:139
本文介绍了超过1000条记录后删除旧记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,
当记录数超过1000时,我需要删除表的旧记录.
我可以设置表中记录的限制吗? 有没有办法自动执行此操作或进行任何查询...
谢谢....

Hello there,
I need to delete the old records of the table when records count exceed the 1000...
can i set the limmit of records in a table...??
is there any way to do it automatically or any query...
thanks....

推荐答案

我个人认为这样做很危险,但是我明白了为什么您可能希望在日志文件或类似文件中使用它.有两种方法可以做到:
1)通过INSERT触发器自动进行(我自己没有尝试过,但是应该可以使用:对于"MySQL触发器",请使用Google,您应该找到足够的信息).
2)通过存储过程进行插入.
I would personally say it is a dangerous thing to do, but I can see why you might want this for a log file or similar. There are two ways to do it:
1) Automatically via an INSERT Trigger (haven''t tried it myself, but it should work: Google for "MySQL Triggers" and you should find enough info).
2) By doing your inserts via a stored procedure.


否,您不能为表设置限制.如果表中有某种日期列(例如插入日期),则可以使用SQL语句删除早于1000条记录的记录.

但是,为什么要限制行数?是因为性能原因还是其他原因?
No, you cannot set a limit to a table. If you have some kind of date column in the table (for example insertion date), you can delete records that are older than the 1000. record using a SQL statement.

But why do you want to limit the amount of rows? Is it because of performance reasons or something else?


这篇关于超过1000条记录后删除旧记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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