MySQL Forums
Forum List  »  Triggers

Re: limit number of rows using a trigger
Posted by: irek kordirko
Date: March 14, 2012 11:48AM

Darren White Wrote:
> ah ok thanks. Do you have a suggestion of a way
> around that then?

Create a procedure that will insert log records into the table,
hide the table from clients using proper grants- don't allow them to directly insert or update this table,
allow them only to call the procedure when they want to store log records in the table.
Code your requirements inside the procedure (if count > 100 delete old records, and insert a new record etc.).

I'am not sure if counting and deleting records on each insert would be very efficient from performance point of view,
in multiuser environment this could lead to contention and scalability issues,
maybe the better option would be to create and event that would be scheduled once per day (or better - at night) and clear unwanted records from the table.

Options: ReplyQuote

Written By
Re: limit number of rows using a trigger
March 14, 2012 11:48AM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.