当前位置:   article > 正文

postgresql支持唯一约束吗_为什么我不能在PostgreSQL中设置这个唯一约束?

detail: key (phone)=(13000000000) is duplicated.

我不断收到:

SQL error: ERROR: could not create

unique index

"service_import_checksum_key" DETAIL:

Key (checksum)=() is duplicated.

在声明中:

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

但是这个约束不是重复的。在整个数据库的任何地方都没有其他约束,我不知道为什么它坚持它是重复的。我假设这是我在这里失踪的postgres的一些奇怪的细微差别。

我究竟做错了什么?

表转储:

--

-- 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

--

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/笔触狂放9/article/detail/606154
推荐阅读
相关标签
  

闽ICP备14008679号