Keo Strife
Keo Strife

Reputation: 1446

SQL auto_increment behaviour

My first question is:

My second question is:

I know I didn't express it so well, but I'm confused and hope someone can help!!

Upvotes: 1

Views: 106

Answers (1)

peterm
peterm

Reputation: 92835

  1. No you can't. An auto_increment column can't contain duplicates and is often used as a primary key. It's possible to have a non-PK auto_increment column as long as you have index on it. There can be only one auto_increment column per table.
  2. Yes, it's possible to insert a value manually into auto_increment field. It will start at MAX value + 1. Therefore you'll have a gap in sequence.

Here is SQLFiddle demo

Further reading Using AUTO_INCREMENT

Upvotes: 2

Related Questions