Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6776699
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:03:36+00:00 2026-05-26T16:03:36+00:00

I need to set a maximum limit of rows in my MySQL table. Documentation

  • 0

I need to set a maximum limit of rows in my MySQL table. Documentation tell us that one can use following SQL code to create table:

CREATE TABLE `table_with_limit` 
   `id` int(11) DEFAULT NULL
) ENGINE=InnoDB MAX_ROWS=100000

But MAX_ROWS property is not a hard limit (“store not more then 100 000 rows and delete other”) but a hint for database engine that this table will have AT LEAST 100 000 rows.

The only possible way I see to solve the problem is to use BEFORE INSERT trigger which will check the count of rows in table and delete the older rows. But I’m pretty sure that this is a huge overheat :/

Another solution is to clear the table with cron script every N minutes. This is a simplest way, but still it needs another system to watch for.

Anyone knows a better solution? 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T16:03:37+00:00Added an answer on May 26, 2026 at 4:03 pm

    Try to make a restriction on adding a new record to a table. Raise an error when a new record is going to be added.

    DELIMITER $$
    
    CREATE TRIGGER trigger1
    BEFORE INSERT
    ON table1
    FOR EACH ROW
    BEGIN
      SELECT COUNT(*) INTO @cnt FROM table1;
      IF @cnt >= 25 THEN
        CALL sth(); -- raise an error
      END IF;
    END
    $$
    
    DELIMITER ;
    

    Note, that COUNT operation may be slow on big InnoDb tables.

    On MySQL 5.5 you can use SIGNAL // RESIGNAL statement to raise an error.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have one mysql table with the following set of records. Product_id reg_price sale_price
I need to set the maximum number of rows in SQL Server Compact 3.5
I need to set a maximum widht to a label tag and avoid the
I need to set up an instance of SQL Server 2005 with SQL_Latin1_General_CP850_Bin as
I need to set up this scenario: A SQL Server 2005 database will create
I've certain situation that requires certain result set from MySQL query, let's see the
I'm using Apache.NMS 1.4. I need to be able to programmatically set the maximum
I need to set maximum height and width of a image in <img> tag.
I need to set the width of <li> based on the maximum string length
I need to set the maximum character input for users simililar to how stackoverflow.com

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.