Home > database >  Repeated injection data
Repeated injection data

Time:09-26

Is inserted into the data found that repeat the primary key, in violation of the uniqueness constraint, unable to write
Excuse me each jumped a great god is there any way to these duplicate data continue to insert data into, or the repeat data directly covered in the past, ~ genuflect is begged

CodePudding user response:


Topic methods and ideas need to be strengthened,

I assume the table for the test, the primary key field for id, insert the source table for TMP
 
Insert into test
Select *
The from TMP a
Left the join the test on b.i b d=Anderson d
Where b.i d is null

CodePudding user response:

Methods and ideas of asking questions

CodePudding user response:

You should not insert, but the merge?

CodePudding user response:

May be describe not clear before, now the problems is that want to use A table of inserting data table B, but the table data in table B primary key repeat data, insert table B time error, think what method can exclude repetitive data, or ignore the duplicate data

CodePudding user response:

reference 4 floor hunter19841209 response:
may be describe not clear before, now the problem is, want to use A table of inserting data table B, but the table data in table B primary key repeat data, insert table B time error, think what method can exclude repetitive data, or ignore the duplicate data


This mean?

The select b.o wner, b.o bject_name
The from b
Where not the exists (select 1 from a where clause b.o bject_id=a.o bject_id);

CodePudding user response:

reference 5 floor minsic78 reply:
Quote: refer to 4th floor hunter19841209 response:

May be describe not clear before, now the problems is that want to use A table of inserting data table B, but the table data in table B primary key repeat data, insert table B time error, think what method can exclude repetitive data, or ignore the duplicate data


This mean?

The select b.o wner, b.o bject_name
The from b
Where not the exists (select 1 from a where clause b.o bject_id=a.o bject_id);


No, copy the wrong SQL

Should be this:
Insert into b
Select a. *
From a
Where not the exists (select 1 from b where b.i d=Anderson, d)

CodePudding user response:

This is according to # 6, insert b table to determine whether the data has existed before

CodePudding user response:

refer to 7th floor yuxiangaaaaa response:
this is according to # 6, insert b table to determine whether the data has existed before line


https://www.cnblogs.com/dongsheng/p/4384754.htmlmerge... To assess the before into execution

CodePudding user response:

refer to the eighth floor yuxiangaaaaa response:
Quote: refer to 7th floor yuxiangaaaaa response:

This is according to # 6, insert b table to determine whether the data has existed before line


https://www.cnblogs.com/dongsheng/p/4384754.html
The merge... To assess the before into execution

CodePudding user response:

If there is whether there has been a repeat, have update, not just insert
It is recommended to use similar
The merge into hwicd. T_handle_reply_info a
Using t_tmp_handle_reply_info b
On (a.h andleid=b.h andleid)
The WHEN MATCHED THEN
UPDATE the SET a.u pdatetime=b.u pdatetime,
A.h andleopinion=b.h andleopinion
WHEN NOT MATCHED THEN
Insert (a.h andleid,
A.o rderid,
Anderson nchargedept,
A.h andleper,
A.h andleopinion,
A.h andledate,
A.s Tate,
A.s tatetime,
A.c reatetime,
A.u pdatetime)
VALUES (b.h andleid,
B.o rderid,
B.i nchargedept,
B.h andleper,
B.h andleopinion,
B.h andledate,
B.s Tate,
B.s tatetime,
The biggest reatetime,
B.u pdatetime);

CodePudding user response:

1 and 6 floor can be implemented

CodePudding user response:

 
Insert into tb1 select tb2. * from tb2
Where tb2. Id not in (select id from tb1)

  • Related