Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Replace vs Update
Message
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00408377
Message ID:
00408586
Views:
12
>>From the Hacker's Guide: "The help hints and our tests confirm that REPLACE is generally faster than UPDATE. In exclusive mode, the differences are small, but with shared tables, we see tremendous differences. The reason for the difference is that UPDATE uses record locking while REPLACE locks the entire table. There may be cases where you can't lock the table, so UPDATE's behavior can save your skin in spite of its performance consequences".

>
>Hello Sylv!
>
>For your reference:
>
>Command           Scope of Lock
>----------------  ---------------------------------------------------
>REPLACE           Current record and all records from aliased fields
>REPLACE NEXT 1    Current record and all records from aliased fields
>REPLACE RECORD n  Record n and all records from aliased fields
>REPLACE of more
>than one record   Entire table and all files from aliased fields
>TABLEUPDATE( )    Depends on buffering
>UPDATE            Entire table
>UPDATESQL      Entire table
>
>
>>Can somebody tell me the difference between using "replace" and "update"?
>>>
>>>I'm using regular VFP database (not MSSQL), I don't use views and usually, I open the tables with buffering mode 5.
>>>
>>>I usually use "replace" and never got problem but I've seen other programmers using "update" and I would like to understand the difference, advantages and pitfalls of both commands.

Where did you get this info, Jess? Is my understanding rigt, that
replace field1 with val1, field2 with val2 would lock one record, while
replace table1.field1 with val1, table1.field2 with val2 the whole table1?
What about replace ... in table1?

I've never paid attention to this before, but it could be important.
TIA
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform