I have a MySQL database with InnoDB tables.
There are different client processes making SELECT (to check the existence of a value) and INSERT or UPDATE (depending on the result of the select) statements.
What I fear is a possible concurrent access to data causing only INSERTs and no UPDATEs.
Is LOCK Table WRITE the only solution?
Tell me more
×
Database Administrators Stack Exchange is a question and answer site for
database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.
|
|
||||
|
|
|
If this table has no other foreign keys attached to it you can try INSERT ... ON DUPLICATE KEY UPDATE or REPLACE INTO (this one deletes an existing row and inserts a new one) This would save you having to select first then insert or update, however it requires that you have a unique key to base the checks on |
|||||
|