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 5980013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:44:29+00:00 2026-05-22T21:44:29+00:00

Assuming this table with nearly 5 000 000 rows CREATE TABLE `author2book` ( `author_id`

  • 0

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.

  • 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-22T21:44:30+00:00Added an answer on May 22, 2026 at 9:44 pm

    You can use ALTER TABLE to add the column and index in one command. i.e.:

    ALTER TABLE author2book ADD id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, ADD PRIMARY KEY (id);
    

    See the MySQL docs for ALTER TABLE for more info.

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

Sidebar

Related Questions

Consider this example table (assuming SQL Server 2005): create table product_bill_of_materials ( parent_product_id int
Assuming I have a table like this one: CREATE TABLE user_delegates ( [id] INT
Difficult to put down in words, so assuming this example table: | id |
Assuming this table is ordered by date id | date | customer 3 |
assuming we use this on a table using select * from table ? i
This is continuing questions from Selecting the highest salary Assuming a table ' wagetable
Possible Duplicate: Importance of varchar length in MySQL table When using VARCHAR (assuming this
I have a MySQL table with following setup: CREATE TABLE IF NOT EXISTS `coords`
I keep getting: SQL error: ERROR: could not create unique index service_import_checksum_key DETAIL: Key
Assuming this is a multi-user system

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.