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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:13:49+00:00 2026-05-24T18:13:49+00:00

How is it possible for a table to have multiple entries for a single

  • 0

How is it possible for a table to have multiple entries for a single primary key in sqlite3 ? This is how I identified the problem:

$ sqlite3 dbName.db
sqlite> .s
CREATE TABLE 'tableName' (
   columnOne INTEGER NOT NULL,
   columnTwo INTEGER NOT NULL,
   columnThree INTEGER NOT NULL,
   columnFour INTEGER NOT NULL,
   columnFive REAL NOT NULL,
   PRIMARY KEY ( columnOne, columnTwo, columnThree, columnFour )
);
sqlite> SELECT count(1) AS nb FROM tableName GROUP BY columnOne, columnTwo, columnThree, columnFour HAVING nb > 1;
[A whole bunch of results, some with nb up to 34!]

UPDATES
A sample of duplicate entries was requested:

$ sqlite3 observation.db
sqlite> .mode column
sqlite> .s
CREATE TABLE 'observation' (
   station INTEGER NOT NULL,
   specie INTEGER NOT NULL,
   isAvg INTEGER NOT NULL,
   date INTEGER NOT NULL,
   value REAL NOT NULL,
   PRIMARY KEY ( station, specie, isAvg, date )
);
sqlite> SELECT * FROM observation WHERE station = 105001 AND specie = 3 AND isAvg = 1 AND date = 1308650400;
station     specie      isAvg       date        value     
----------  ----------  ----------  ----------  ----------
105001      3           1           1308650400  31.0      
105001      3           1           1308650400  2.42523266
105001      3           1           1308650400  2.42523266
105001      3           1           1308650400  2.42523266
105001      3           1           1308650400  2.42523266
105001      3           1           1308650400  2.42523266
105001      3           1           1308650400  2.42523266
105001      3           1           1308650400  2.42523266
105001      3           1           1308650400  2.42523266
105001      3           1           1308650400  2.42523266
105001      3           1           1308650400  2.42523266
105001      3           1           1308650400  2.42523266
105001      3           1           1308650400  2.42523266
105001      3           1           1308650400  2.42523266
105001      3           1           1308650400  2.42523266
105001      3           1           1308650400  2.42523266
105001      3           1           1308650400  2.42523266
105001      3           1           1308650400  2.42523266
105001      3           1           1308650400  2.42523266
105001      3           1           1308650400  2.42523266
105001      3           1           1308650400  2.42523266
105001      3           1           1308650400  2.42523266
105001      3           1           1308650400  2.42523266
105001      3           1           1308650400  2.42523266
105001      3           1           1308650400  2.42523266
105001      3           1           1308650400  2.42523266
105001      3           1           1308650400  2.42523266
105001      3           1           1308650400  2.42523266
105001      3           1           1308650400  2.42523266
105001      3           1           1308650400  2.42523266
105001      3           1           1308650400  2.42523266
105001      3           1           1308650400  2.42523266
105001      3           1           1308650400  2.42523266
105001      3           1           1308650400  2.42523266

@mu is too short : The database is filled by a tcl script which runs every hour and uses one of the following queries to insert data :

INSERT OR REPLACE INTO observation (station, specie, isAvg, date, value) VALUES ($stationId, $speciesId, 0, $date, $value);

INSERT OR REPLACE INTO observation (station, specie, isAvg, date, value) VALUES (${stationId}, ${speciesId}, 1, ${date}, ${speciesAvg});

I just thought of something else, I don’t know if this can help… :

sqlite3 observation.db
sqlite> pragma integrity_check;
integrity_check
rowid 53202997 missing from index sqlite_autoindex_observation_1
rowid 53202998 missing from index sqlite_autoindex_observation_1
rowid 53202999 missing from index sqlite_autoindex_observation_1
rowid 53203000 missing from index sqlite_autoindex_observation_1
rowid 53203006 missing from index sqlite_autoindex_observation_1
rowid 53584951 missing from index sqlite_autoindex_observation_1
[...]
and more of the same (100 such lines since integrity_check stops at 100 by default..)
[...]
  • 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-24T18:13:50+00:00Added an answer on May 24, 2026 at 6:13 pm

    To answer your question directly:
    It is only possible when there is an error with your primary key index.

    The problem is shown by your integrity_check error, since sqlite3 uses this index to determine primary key uniqueness. When the index is bad you will be able to insert duplicate records

    To solve: I would build and repopulate a new table. Remember when you copy the records you will need to deal with these duplicate records.

    Also, you don’t show your sqlite3 version number, that would help in solving the problem.

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

Sidebar

Related Questions

I'll simplify the problem as much as possible: I have an oracle table: row_priority,
It's possible to find a table name by an id? I have multiple tables
I have a table (venues) that stores all the possible venues a volunteer can
Is it possible to have same table name on different schema with different data
Is it possible to have an association mapping a table to itself? e.g. Table:
Is it possible to have a relationship from a user table to a system
Is it at all possible to do database-agnostic table dumps/hydrates? I don't have any
Is it possible to edit computed-column values? I have a computed-col in my table,
I'm wondering if this is possible in SQL. Say you have two tables A
I'm guessing this isn't possible, but here goes. I have two tables, and I'm

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.