MySQl Table Crashing for no reason

Discussion in 'MySQL' started by theextelligence, Nov 11, 2009.

  1. #1
    HI

    I have a table

    
    CREATE TABLE `poll_results` (                                                                                                      
                    `id` int(5) unsigned NOT NULL auto_increment,                                                                                    
                    `poll_id` int(5) default NULL,                                                                                                   
                    `poll_choice_id` int(5) default NULL,                                                                                            
                    `hits` int(5) default '0',                                                                                                       
                    `status_id` tinyint(2) default '1',                                                                                              
                    PRIMARY KEY  (`id`),                                                                                                             
                    KEY `FK_poll_results` (`poll_id`),                                                                                               
                    KEY `FK_poll_results_choice` (`poll_choice_id`),                                                                                 
                    KEY `FK_poll_results_status` (`status_id`)                                                                                       
                  ) ENGINE=MyISAM AUTO_INCREMENT=4 DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci CHECKSUM=1 DELAY_KEY_WRITE=1 ROW_FORMAT=DYNAMIC  
    
    Code (markup):

    I am running this command to insert 3 records in my new table

    INSERT INTO `poll_results` (`hits`, `status_id`, `poll_id`, `poll_choice_id`) VALUES (0, 1, 1, 3);
    INSERT INTO `poll_results` (`hits`, `status_id`, `poll_id`, `poll_choice_id`) VALUES (0, 1, 1, 2);
    INSERT INTO `poll_results` (`hits`, `status_id`, `poll_id`, `poll_choice_id`) VALUES (0, 1, 1, 1);
    Code (markup):

    All goes well until I fire this command, my table "poll_results" crashes...

    
    UPDATE `poll_results` AS `PollResult`  SET `PollResult`.`hits` = 1; 
    Code (markup):
    I get this error

    Table 'poll_results' is marked as crashed and should be repaired
    Code (markup):


    Why on earth the mysql table crash only to update 3 records?

    MySql Version is 5.0.45-community-nt


    Pls someone suggest.


    Many thanks
     
    theextelligence, Nov 11, 2009 IP
  2. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #2
    Try running via SQL command line.

    REPAIR TABLE poll_results;
     
    jestep, Nov 12, 2009 IP
  3. donmarcos

    donmarcos Peon

    Messages:
    17
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Question :

    why are you doing the update like this

    UPDATE `poll_results` AS `PollResult` SET `PollResult`.`hits` = 1;

    when you can do it like this

    UPDATE poll_results SET hits = 1;

    and get rid of those back ticks




     
    donmarcos, Nov 13, 2009 IP
  4. Davidpoul

    Davidpoul Active Member

    Messages:
    50
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    51
    #4
    Try to repair your table using

    REPAIR TABLE poll_results;

    David
     
    Davidpoul, Feb 18, 2010 IP