Jump to content

I just have a question about a database table.


Strider64
Go to solution Solved by Barand,

Recommended Posts

I have updated a online trivia game and used an old database table that has existing questions.  I was wondering if the new questions would overwrite existing questions because questions have been deleted in the past with this database table?

Thanks in Advance,

      John

Edited by Strider64
Link to comment
Share on other sites

What I mean is the id field (Auto Increment) start at 1 and I have existing records that have an id of 130 lets say. I wrote new questions/answers and it started back at 1. So if I add more questions that get up to say 130 will the exist questioning be OVER WRITTEN 🙄If I get another rude reply I am going to delete this account and use other forums. You would think a person who didn't understand what I was writing would say could you clarify it and to top it all it's an administrator that made the reply.

Edited by Strider64
Link to comment
Share on other sites

22 hours ago, Strider64 said:

. You would think a person who didn't understand what I was writing would say could you clarify it and to top it all it's an administrator that made the reply.

I believe it was meant as a colorful reply.  Requinix is saying that things will "explode". 

What I believe will happen is that auto_increment will not work the way you expect.  

Rather than start at 1, the first allocated auto_increment value will be the largest id that exists, plus 1.  So the first new inserted value in the table will have id 31. 

There won't be an error, so I guess the main question is whether or not you actually care about the loss of available key values.

BTW, a similar issue exists with tables you might truncate or delete all values from.  That does not by itself reset the auto_increment value.  You can however, use a mysql/mariadb specific sql statement on the table to reset the auto_increment counter back to 1

ALTER TABLE tablename AUTO_INCREMENT = 1

This however would not work with Innodb tables (which is what you should always be using with mysql) as the auto_increment counter can never be set below the highest available one that exists.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.