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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:52:46+00:00 2026-05-26T18:52:46+00:00

I set up a database, with an auto incrementing column that was meant to

  • 0

I set up a database, with an auto incrementing column that was meant to be an ID. The problem is that I forgot to check off auto increment when creating the table in phpMyAdmin…and didn’t notice until now! So what I have is something like:

ID   |   column one   |   column two
------------------------------------
0    |   some value   |   some value
0    |   other value  |   something else
0    |   example val. |   something
0    |   my example   |   something

Basically, my “auto incrementing” column shows zeros across the board. How could I modify this table to show auto increment for all previous and all future rows?

  • 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-26T18:52:46+00:00Added an answer on May 26, 2026 at 6:52 pm

    If the table were empty you could just do:

    ALTER TABLE mytable MODIFY COLUMN id bigint not null primary key auto_increment
    

    but I’m not sure what will happen with rows in it. It might be best to create a new one with the correct definitions, copy the data over minus the id column, drop the old (wrong) table, and move the new one to the old name.

    -- Either: 
    CREATE TABLE newtable LIKE mytable;
    ALTER TABLE newtable MODIFY COLUMN id bigint not null primary key auto_increment;
    -- or:
    CREATE TABLE newtable (
        id bigint not null primary key auto_increment,
        column1 type1,
        column2 type2,
        ...
    );
    
    INSERT INTO newtable 
        (column1, column2, ...) 
        SELECT column1, column2, column3, ... 
        FROM mytable;
    -- Make SURE that insert worked BEFORE you drop the old table 
    -- and lose data if it didn't.
    DROP TABLE mytable;
    ALTER TABLE newtable RENAME TO mytable;
    

    I’m sure phpMyAdmin has the ability to do this more graphically.

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

Sidebar

Related Questions

How to set two column in SQL Server database as auto increment int with
In a MySQL database column that has been set to AUTO_INCREMENT , can I
i'm using NHibernate with Sdf database. In my hibernate.cfg.xml file i've set: <property name=hbm2ddl.auto
If I set a database column as an autonumber primary key field, will the
We can set our DataBase read-only, and it restricts some commands like Auto-Shrink, Auto
I have a non-nullable database column which has a default value set. When inserting
I have a property that is set to 1 if the database feature is
I have a MS SQL Srver 2005 Database, that has a table with a
I have two database tables: 'MyTable' which has a standard auto-incrementing primary key integer
I have the following mysql table schema: SET SQL_MODE=NO_AUTO_VALUE_ON_ZERO; -- -- Database: `network` --

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.