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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T01:54:29+00:00 2026-06-05T01:54:29+00:00

If I have a table A with column INCREMENT_NUMBER. We will say that there

  • 0

If I have a table A with column INCREMENT_NUMBER. We will say that there are five rows.

1
2
3
4
4

If a user adds a new row to table A, the INCREMENT_NUMBER column of that row should be 5. (It could be anything, as long as it isn’t a number 1-4.) Keep in mind

INCREMENT_NUMBER integer auto_increment primary key

will not work because I need to allow for duplicates in the table and I don’t think

insert
  • 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-05T01:54:30+00:00Added an answer on June 5, 2026 at 1:54 am

    If you want to allow duplicates, don’t declare it as a PRIMARY KEY (and neither put a UNIQUE constraint on it).

    In MySQL an AUTO_INCREMENT is allowed to have duplicates in that case – you just have to add a simple index on it:

    CREATE TABLE test
    ( increment_number INTEGER NOT NULL AUTO_INCREMENT
    , INDEX inc_index (increment_number)
    ) ;
    
    INSERT INTO test
    VALUES (1),(2),(3),(4),(4);
    

    Test in SQL-Fiddle: test-1

    INSERT INTO test
    VALUES
    (NULL);
    
    SELECT *
    FROM test ;
    

    Results in:

    increment_number
    ----------------
    1
    2
    3
    4
    4
    5
    

    In SQL-Server, you’ll have to toggle the IDENTITY_INSERT setting ON and OFF to have similar behaviour:

    CREATE TABLE test
    ( increment_number INT IDENTITY(1,1) NOT NULL 
    , name varchar(20) NOT NULL
    ) ;
    
    SET IDENTITY_INSERT test ON ;
    
    INSERT INTO test (increment_number, name)
    VALUES 
    (1, 'Alex'),
    (2, 'Bill'),
    (3, 'Cathy'),
    (4, 'Diana'),
    (4, 'Dean');
    

    And then test-2:

    SET IDENTITY_INSERT test OFF ;
    
    INSERT INTO test (name)
    VALUES
    ('Elaine') ;
    
    SELECT *
    FROM test ;
    

    Results in:

    increment_number  |  name
    ---------------------------
    1                    Alex
    2                    Bill
    3                    Cathy
    4                    Diana
    4                    Dean
    5                    Elaine 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table with an identity column that have incremented by 1 for
I have a table column where each row has one of three states, and
I have a workqueue table that has a workid column. The workID column has
Lets say that I have two tables. Table 1 is a list of vendors
Let's say that I want to have a table that logs the date and
In MySql I could have a table with an auto increment column and insert
Lets say I have table named Place with columns: placeId int not null auto_increment,
I have table v_c_country with column table_name I can make an query and, as
I have a table column I’m trying to expand and hide. jQuery seems to
I have a table column called post_tags within a table called posts where assigned

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.