Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
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....
Posted

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.
 
Share this answer
 
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?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900