Assuming this table with nearly 5 000 000 rows
CREATE TABLE `author2book` (
`author_id` int(11) NOT NULL,
`book_id` int(11) NOT NULL,
KEY `author_id_INDEX` (`author_id`),
KEY `paper_id_INDEX` (`book_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
is it possible to add a primary index column id with autoincrement as first place? I expect something like this:
CREATE TABLE `author2book` (
`id` int(11) NOT NULL AUTO_INCREMENT, <<<< This is what I try to achieve!
`author_id` int(11) NOT NULL,
`book_id` int(11) NOT NULL,
KEY `author_id_INDEX` (`author_id`),
KEY `paper_id_INDEX` (`book_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
Is this possible?
Edit: I should mention, that I’d like the added column to be populated.
You can use ALTER TABLE to add the column and index in one command. i.e.:
See the MySQL docs for ALTER TABLE for more info.