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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T10:11:45+00:00 2026-06-12T10:11:45+00:00

Possible Duplicate: How to force MySQL to take 0 as a valid auto-increment value

  • 0

Possible Duplicate:
How to force MySQL to take 0 as a valid auto-increment value

I know I can do an update on an existing row, but is it possible to INSERT a row with the id 0?

mysql> create table inc( id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, sz TEXT);
Query OK, 0 rows affected (0.10 sec)

mysql> insert into inc(id, sz) select 25, "a";
Query OK, 1 row affected (0.02 sec)
Records: 1  Duplicates: 0  Warnings: 0

mysql> insert into inc(id, sz) select 25, "a";
ERROR 1062 (23000): Duplicate entry '25' for key 'PRIMARY'
mysql> insert into inc(id, sz) select 27, "b";
Query OK, 1 row affected (0.04 sec)
Records: 1  Duplicates: 0  Warnings: 0

mysql> insert into inc(id, sz) select -5, "c";
Query OK, 1 row affected (0.03 sec)
Records: 1  Duplicates: 0  Warnings: 0

mysql> insert into inc(id, sz) select 0, "d";
Query OK, 1 row affected (0.15 sec)
Records: 1  Duplicates: 0  Warnings: 0

mysql> select * from inc;
+----+------+
| id | sz   |
+----+------+
| -5 | c    |
| 25 | a    |
| 27 | b    |
| 28 | d    |
+----+------+
4 rows in set (0.00 sec)
  • 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-06-12T10:11:46+00:00Added an answer on June 12, 2026 at 10:11 am

    From http://dev.mysql.com/doc/refman/5.0/en/example-auto-increment.html

    “No value was specified for the AUTO_INCREMENT column, so MySQL assigned sequence numbers automatically. You can also explicitly assign NULL or 0 to the column to generate sequence numbers.”

    So it seems using 0 just tells it to auto_increment.

    But if you are assigning ID numbers, I’m not sure why you have defined the column to use AUTO_INCREMENT?

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

Sidebar

Related Questions

Possible Duplicate: Mobile site - force landscape only / no auto-rotate I have seen
Possible Duplicate: Forcing Garbage Collection in Java? Can I Force Garbage Collection in Java
Possible Duplicate: How to force a pdf download automatically? I've checked other forums, but
Possible Duplicate: CSS: how can I force a long string (without any blank) to
Possible Duplicate: Javascript force open a link in a browser I am working on
Possible Duplicate: How can I convert a list<> to a multi-dimensional array? I want
Possible Duplicate: How can I understand nested ?: operators in PHP? Why does this:
Possible Duplicate: Can main function call itself in C++? I found this problem very
Possible duplicate: why does the css min-width attribute not force a div to hae
Possible Duplicate: Force Download an Image Using Javascript Basically I want to have the

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.