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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T09:20:33+00:00 2026-05-31T09:20:33+00:00

I have a table that looks like this CREATE TABLE IF NOT EXISTS `language`

  • 0

I have a table that looks like this

CREATE TABLE IF NOT EXISTS `language` (
   `idkey` int(10) unsigned NOT NULL AUTO_INCREMENT,
   `english_lang` text,
   `japanese_lang` text,
   PRIMARY KEY (`idkey`),
 ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1587 ;

The ‘idkey’ is just a number that starts at 1 and increments.

The ‘idkey’ currently has gaps in the numbering from entries I’ve removed and I wanted to see if it was possible to run a MySQL command to re-write this column so there are no gaps in the numbering.

eg: rewrite it so it starts at 1 and runnings till the end (around 1400 entries).

thanks

  • 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-31T09:20:35+00:00Added an answer on May 31, 2026 at 9:20 am

    It is against standard practices to try to fill in these “missing numbers”. You need to consider that they were once assigned to something. Assigning them now to something else could potentially lead to problems–especially if you’re not using foreign key constraints and have some bad data sitting around.

    If you are in a situation where you tested some data and now want to take things live, you can reset the auto-increment by running Alter Table TABLENAME AUTO_INCREMENT=1 (or any other number) or you can drop and recreate the table. If it has been in production I would recommend against resetting or trying to “fill in the gaps”.

    In the interest of completeness I believe you can insert a specific number in a normally auto incrementing column by including it in your insert statement. The next auto increment number should pick up from the one you specified. If it’s already taken this will cause you problems.

    If you really just want to close up gaps the easiest way is to create a new table with the same structure. Then run a query like:

    INSERT INTO 
        newtable (column2, column3, column4,...) 
    VALUES 
        SELECT column2, column3, column4,... FROM oldtable;
    

    The drop the old table and rename the new table. The gaps will be filled in and your auto increment number will be at the “correct” place.

    BUT REALLY YOU SHOULD LEAVE GAPS FROM DELETED RECORDS IN PLACE.

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

Sidebar

Related Questions

I have a database table that looks like this: CREATE TABLE IF NOT EXISTS
Hi there I have an SQL table that looks like this: CREATE TABLE IF
I have a table that simplified looks like this: create table Test ( ValidFrom
I have a table that looks like this: nid vid tid 1 2 3
I have a table that looks like this: <table> <thead> <!-- random table headings
I have a table that looks like this: |StreetName NR| NR | |Teststreet 34|
I have a table that looks like this: id count 1 100 2 50
I have a table that looks like this for about ~30 students: StudentID Course*
So I have a table that looks like this: ProjectID TaskID Date 000 001
I have a table that looks something like this: word big expensive smart fast

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.