> -----Original Message-----
> From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-
> boun...@sqlite.org] On Behalf Of Richard Hipp
> Sent: Tuesday, May 27, 2014 2:15 PM
> To: General Discussion of SQLite Database
> Subject: Re: [sqlite] DELETE & INSERT vs. REPLACE
>
> On Tue, May 27, 2014 at 2:11 PM, Drago, William @ MWG - NARDAEAST <
> william.dr...@l-3com.com> wrote:
>
> > All,
> >
> > Is there any difference between using REPLACE as opposed to deleting
> > records and then inserting new ones to take their place?
> >
>
> REPLACE only deletes records when it is absolutely necessary to
> preserve UNIQUE constraints on an insert.  As long as you restrict your
> deletes to records that would otherwise cause a uniqueness conflict,
> then the result will be the same.


There are no uniqueness constraints on this table.

Let me rephrase the question by asking, how should I overwrite existing data? 
For example, Jane has 5 guitars in her instrument table. She trades her 5 
guitars for 5 new ones. Almost everything about the new guitars is different 
from the old guitars.

My gut tells me I should simply delete where instrument_type = 'guitar' and 
then insert the new data. If there's a better way (i.e. healthier for the 
database) then I'd like to know. In my real world automatic test application 
things like will happen very infrequently, but they will occasionally happen. 
And, if it matters, this is a very low volume database. No more than a dozen or 
so inserts/reads per day.

I'd like to keep the database healthy by not doing inefficient things to it and 
I'm new to both SQLite and SQL. That's why I'm asking this question.

Thanks,
-Bill

> --
> D. Richard Hipp
> d...@sqlite.org
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
CONFIDENTIALITY, EXPORT CONTROL AND DISCLAIMER NOTE:This e-mail and any 
attachments are solely for the use of the addressee and may contain information 
that is privileged or confidential. Any disclosure, use or distribution of the 
information contained herein is prohibited. In the event this e-mail contains 
technical data within the definition of the International Traffic in Arms 
Regulations or Export Administration Regulations, it is subject to the export 
control laws of the U.S.Government. The recipient should check this e-mail and 
any attachments for the presence of viruses as L-3 does not accept any 
liability associated with the transmission of this e-mail. If you have received 
this communication in error, please notify the sender by reply e-mail and 
immediately delete this message and any attachments.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to