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

  • SEARCH
  • Home
  • 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 6212473
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:31:21+00:00 2026-05-24T06:31:21+00:00

I created a table in MySQL with on column itemID . After creating the

  • 0

I created a table in MySQL with on column itemID.

After creating the table, now I want to change this column to AUTOINCREMENT.

How can this be done using ALTER statements?

Table definition:

ALLITEMS (itemid int(10) unsigned, itemname varchar(50))

I am using the following code but it is throwing a syntax error

Error: syntax incorrect.

ALTER TABLE allitems
MODIFY itemid INT(10) UNSIGNED AUTOINCREMENT; 
  • 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-24T06:31:21+00:00Added an answer on May 24, 2026 at 6:31 am
    CREATE TABLE ALLITEMS(
        itemid INT(10)UNSIGNED,
        itemname VARCHAR(50)
    );
    
    ALTER TABLE ALLITEMS CHANGE itemid itemid INT(10)AUTO_INCREMENT PRIMARY KEY;
    
    DESC ALLITEMS;
    
    INSERT INTO ALLITEMS(itemname)
    VALUES
        ('Apple'),
        ('Orange'),
        ('Banana');
    
    SELECT
        *
    FROM
        ALLITEMS;
    

    I was confused with CHANGE and MODIFY keywords before too:

    ALTER TABLE ALLITEMS CHANGE itemid itemid INT(10)AUTO_INCREMENT PRIMARY KEY;
    
    ALTER TABLE ALLITEMS MODIFY itemid INT(5);
    

    While we are there, also note that AUTO_INCREMENT can also start with a predefined number:

    ALTER TABLE tbl AUTO_INCREMENT = 100;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I created a MySQL database with a table using phpmyadmin. I created this table
I want to create a new column in a MYSQL table that has Fn
I have an ISAm table in mySql that was created similar to this: create
I have this in a MySQL db: table Message sender_id int recipient_id int created
If I'm adding a column via MySQL, I can specify where in the table
I created a table in MySQL with a column of type float(2,2) and inserted
according to the reference (http://dev.mysql.com/doc/refman/5.5/en/create-table.html), MySQL 5.5 now supports table and column comments of
I have a MySQL table with a datetime column named 'created' which contains the
Using the MySQL query below, I have created a pivot table which is pretty
In my MySQL table I've created an ID column which I'm hoping to auto-increment

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.