> -----Original Message----- > From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users- > boun...@sqlite.org] On Behalf Of Simon Slavin > Sent: Tuesday, May 27, 2014 5:21 PM > To: General Discussion of SQLite Database > Subject: Re: [sqlite] DELETE & INSERT vs. REPLACE > > > On 27 May 2014, at 9:12pm, Drago, William @ MWG - NARDAEAST > <william.dr...@l-3com.com> wrote: > > > 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. > > Go with your gut. Since there's no relationship between the old and > new guitars it would be just as likely that Jane would replace 5 > guitars with 4 guitars, having sold two cheap ones and bought one > expensive one. You should not be using REPLACE, you should be using > DELETE, then INSERT, with the correct number of each type of command. > > Of course, unless your entire databases is about Jane's guitars that's > not a good table to create. You would be more likely to have a > database about everything Jane owns, or a database about all the > guitars lots of people owns.
Thank you. That's good news and I don't have to change any of my code. Can someone tell me what an appropriate use for REPLACE is? -Bill 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