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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T06:34:43+00:00 2026-05-20T06:34:43+00:00

I keep getting: SQL error: ERROR: could not create unique index service_import_checksum_key DETAIL: Key

  • 0

I keep getting:

SQL error: ERROR: could not create
unique index
“service_import_checksum_key” DETAIL:
Key (checksum)=() is duplicated.

In statement:

ALTER TABLE “public”.”service_import” ADD CONSTRAINT “service_import_checksum_key” UNIQUE (“checksum”)

But this constraint ISN’T a duplicate. There is no other constraint like this anywhere in the entire database and I have no idea why on earth it keeps insisting it’s a duplicate. I’m assuming this is some weird nuance of postgres that I’m missing here.

What am I doing wrong?

Table dump:

--
-- PostgreSQL database dump
--

SET statement_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = off;
SET check_function_bodies = false;
SET client_min_messages = warning;
SET escape_string_warning = off;

SET search_path = public, pg_catalog;

SET default_tablespace = '';

SET default_with_oids = false;

--
-- Name: service_import; Type: TABLE; Schema: public; Owner: cvs_tar; Tablespace: 
--

CREATE TABLE service_import (
    id integer NOT NULL,
    name character varying(32) NOT NULL,
    importfile character varying(64) NOT NULL,
    reportfile character varying(64) NOT NULL,
    percent smallint NOT NULL,
    message text NOT NULL,
    stamp timestamp without time zone DEFAULT now() NOT NULL,
    complete smallint DEFAULT 0 NOT NULL,
    checksum character varying(40) NOT NULL
);


ALTER TABLE public.service_import OWNER TO cvs_tar;

--
-- Name: service_imports_id_seq; Type: SEQUENCE; Schema: public; Owner: cvs_tar
--

CREATE SEQUENCE service_imports_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.service_imports_id_seq OWNER TO cvs_tar;

--
-- Name: service_imports_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: cvs_tar
--

ALTER SEQUENCE service_imports_id_seq OWNED BY service_import.id;


--
-- Name: id; Type: DEFAULT; Schema: public; Owner: cvs_tar
--

ALTER TABLE service_import ALTER COLUMN id SET DEFAULT nextval('service_imports_id_seq'::regclass);


--
-- Name: service_import_name_key; Type: CONSTRAINT; Schema: public; Owner: cvs_tar; Tablespace: 
--

ALTER TABLE ONLY service_import
    ADD CONSTRAINT service_import_name_key UNIQUE (name);


--
-- Name: service_import_pkey; Type: CONSTRAINT; Schema: public; Owner: cvs_tar; Tablespace: 
--

ALTER TABLE ONLY service_import
    ADD CONSTRAINT service_import_pkey PRIMARY KEY (id);


--
-- Name: service_import_complete_idx; Type: INDEX; Schema: public; Owner: cvs_tar; Tablespace: 
--

CREATE INDEX service_import_complete_idx ON service_import USING btree (complete);


--
-- Name: service_import_stamp_idx; Type: INDEX; Schema: public; Owner: cvs_tar; Tablespace: 
--

CREATE INDEX service_import_stamp_idx ON service_import USING btree (stamp);


--
-- PostgreSQL database dump complete
--
  • 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-20T06:34:44+00:00Added an answer on May 20, 2026 at 6:34 am

    Read the error message again:

    SQL error: ERROR: could not create unique index “service_import_checksum_key”
    DETAIL: Key (checksum)=() is duplicated.

    Looks like it is telling you that there are duplicate values in the checksum column and you’re trying to enforce uniqueness on that column with your constraint. The constraint isn’t duplicated, the data has duplicates.

    Furthermore, the “()” part indicates that you have multiple empty strings in the checksum column. Unique constraints allow multiple NULL values (since NULL = NULL is NULL which is not true) but empty strings are not NULL.

    An example to clarify what’s going on:

    => CREATE TABLE x (s VARCHAR NULL);
    CREATE TABLE
    => INSERT INTO x (s) VALUES (''), ('a'), ('');
    INSERT 0 3
    => ALTER TABLE x ADD CONSTRAINT ux UNIQUE(s);
    NOTICE:  ALTER TABLE / ADD UNIQUE will create implicit index "ux" for table "x"
    ERROR:  could not create unique index "ux"
    DETAIL:  Key (s)=() is duplicated.
    => delete from x where s='';
    DELETE 2
    => INSERT INTO x (s) VALUES ('a');
    INSERT 0 1
    => ALTER TABLE x ADD CONSTRAINT ux UNIQUE(s);
    NOTICE:  ALTER TABLE / ADD UNIQUE will create implicit index "ux" for table "x"
    ERROR:  could not create unique index "ux"
    DETAIL:  Key (s)=(a) is duplicated.
    

    In particular, note what the ERROR and DETAIL are saying and compare that to the INSERTs.

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

Sidebar

Related Questions

I keep getting a PermGen error on my Tomcat 6 server. I know what
I want to rename a database, but keep getting the error that 'couldn't get
We keep getting this error randomly in our web application. System.Data.SqlClient.SqlException: A network-related or
I keep getting tasks that are above my skill level. How can I address this without coming accross as grossly incompetent?
I keep getting compiler errors when I try to access flashVars in an AS3
I keep getting asked about AppDomains in interviews, and I know the basics :
I keep getting stuck conceptually on deciding an Exception-handling structure for my project. Suppose
I keep getting this NPE in my application and I can't seem to get
When building static libraries with VS2005 I keep getting linker warnings that VC80.pdb cant
I'm trying to do a simple erase and keep getting errors. Here is 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.