数据仓库服务 GAUSSDB(DWS)-向表中插入数据报错:duplicate key value violates unique constraint "%s":问题现象

时间:2024-05-07 20:29:47

问题现象

向表中插入数据报错:duplicate key value violates unique constraint "%s"。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
CREATE TABLE films (
code        char(5) PRIMARY KEY,
title       varchar(40) NOT NULL,
did         integer NOT NULL,
date_prod   date,
kind        varchar(10),
len         interval hour to minute
);
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "films_pkey" for table "films"
CREATE TABLE

INSERT INTO films VALUES ('UA502', 'Bananas', 105, DEFAULT, 'Comedy', '82 minutes');
INSERT INTO films VALUES ('UA502', 'Bananas', 105, '1971-07-13', 'Comedy', '82 minutes');
ERROR:  dn_6003_6004: duplicate key value violates unique constraint "films_pkey"
DETAIL:  Key (code)=(UA502) already exists.
support.huaweicloud.com/trouble-dws/dws_09_0123.html