Go back to the main page

Properly set up an auto incremented composite key with MySQL

 

Remember to put the "auto_increment" row SECOND and the engine must be MyISAM.

CREATE TABLE `issue_numbers` (
  `list_id` int(11) NOT NULL,
  `id` int(11) NOT NULL AUTO_INCREMENT,
    PRIMARY KEY (`list_id`,`id`)
    ) ENGINE=MyISAM  ;
    

  • Pushed on 06/01/2013 by Christian