how to create a fixed size table in mysql

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #16
    Your syntax is off. This is off the top of my head as I don't have MySQL to test it against where I am currently. The basic syntax will look kind of like this:
    Code:
    DELIMITER |
    
    CREATE TRIGGER triggerName
    BEFORE INSERT ON tableName
    FOR EACH ROW
    
    BEGIN
    DECLARE num_rows INTEGER;
    
    SELECT COUNT(*)
    INTO num_rows
    FROM tableName;
    
    IF num_rows > 6 THEN
       DELETE FROM tableName LIMIT 1;
    END IF;
    
    |
    DELIMITER ;
    There's no need to do another insert. It's already going to insert.
    Last edited by Rabbit; Nov 5 '12, 05:59 PM.

    Comment

    • PreethiGowri
      New Member
      • Oct 2012
      • 126

      #17
      i have a doubt can multiple tables of same database have triggers??

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #18
        I'm not sure what that means but if there's a hard limit on the number of triggers you can have, it would be a fairly high number. But I doubt you have any other triggers than this one since you said you said you were new to triggers. So I must have misunderstood your meaning.

        Comment

        Working...