明显不工作?
我需要在表中插入一些字段。表:
CREATE TABLE RADAR(
ctfoto VARCHAR2(5),
pkradar NUMBER(3,0),
sradar VARCHAR2(3),
limitvelctera NUMBER(3,0),
limitvelradar NUMBER(3,0),
CONSTRAINT radar_pk PRIMARY KEY(ctfoto, pkradar, sradar)
);
插入操作:
INSERT INTO RADAR(ctfoto, pkradar, sradar, limitvelctera, limitvelradar)
SELECT distinct carretera_foto, pto_km_radar, sentido_radar, limit_vel_ctera, limit_vel_radar FROM gotcha
错误:
ORA-00001: unique constraint (USER4704.RADAR_PK) violated
请帮忙。
I need to insert some field in a table. The table:
CREATE TABLE RADAR(
ctfoto VARCHAR2(5),
pkradar NUMBER(3,0),
sradar VARCHAR2(3),
limitvelctera NUMBER(3,0),
limitvelradar NUMBER(3,0),
CONSTRAINT radar_pk PRIMARY KEY(ctfoto, pkradar, sradar)
);
The insert operation:
INSERT INTO RADAR(ctfoto, pkradar, sradar, limitvelctera, limitvelradar)
SELECT distinct carretera_foto, pto_km_radar, sentido_radar, limit_vel_ctera, limit_vel_radar FROM gotcha
The error:
ORA-00001: unique constraint (USER4704.RADAR_PK) violated
Please help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
DISTINCT
适用于您选择的整组列。很有可能,
GOTCHA
中的行具有相同的carretera_foto
、pto_km_radar
和sentido_radar
值,但不同其他两列之一或两列(limit_vel_ctera
和limit_vel_radar
)的值。SELECT
中的DISTINCT
无法消除任一行,因为至少有一个值不同,但RADAR
表上的主键约束拒绝行其中前三列是相同的。DISTINCT
applies to the entire set of columns you are selecting.In all probability, you have rows in
GOTCHA
that have the samecarretera_foto
,pto_km_radar
, andsentido_radar
values but different values for one or both of the other two columns (limit_vel_ctera
andlimit_vel_radar
). TheDISTINCT
in yourSELECT
cannot eliminate either of the rows because at least one value is different but the primary key constraint on theRADAR
table rejects rows where the first three columns are identical.您在
gotcha
中可能有多个记录,其字段carretera_foto、pto_km_radar、sentido_radar
中的值相同。DISTINCT
表示整个记录不会重复。You probably have more than one record in
gotcha
with the same values in fieldscarretera_foto, pto_km_radar, sentido_radar
.DISTINCT
means the whole record will not be repeated.