Re: Duplicate entry '0' for key 'PRIMARY'

From: Thomas 'PointedEars' Lahn <PointedEars_at_web.de>
Date: Sat, 15 Apr 2017 15:19:33 +0200
Message-ID: <4258543.GXAFRqVoOG_at_PointedEars.de>


Peter H. Coffin wrote:

> On Tue, 11 Apr 2017 08:36:17 -0400, Jerry Stuckle wrote:

>> In either case the database will be seriously borked with foreign keys
>> pointing at the wrong data.

>
> And that is, im my humble opinion, a point of such importance that it
> may as well be the ONLY point.

AISB, as long as one is *aware* that any foreign keys referring to that table are then invalid, too, then there is no problem. If there are (nonNULL)  foreign keys referring that table, then one should work with a *copy* of either the target table or the target database.

[Quoted] But apparently I have to emphasize *again* that the target table *in this case* was *empty*. Any non-NULL foreign keys referring to it would have been *invalid in the first place*, and NULL foreign keys would not matter.

> Data integrity is paramount.

So much for that.

> Build the table without a primary key, FIND THE DUPLICATES, resolve them
> (by hand, if necessary) so that the data is intact and correct, THEN add
> the primary key back.

ACK, and the mere *attempt* to add the primary key (or any other key) (back) with key checks *enabled* will *result* in *detecting* those inconsistencies already. AISB.  

-- 
PointedEars

Twitter: _at_PointedEars2
Please do not cc me. / Bitte keine Kopien per E-Mail.
Received on Sat Apr 15 2017 - 15:19:33 CEST

Original text of this message