Database Reference
In-Depth Information
Make sure every table has a primary key (refer to Chapter 15, “Joining
Tables,” if you have forgotten what this is) and use it as the WHERE
clause whenever possible. (You may specify individual primary keys,
multiple values, or value ranges.)
Before you use a WHERE clause with an UPDATE or a DELETE , first test
it with a SELECT to make sure it is filtering the right records—it is far
too easy to write incorrect WHERE clauses.
Use database enforced referential integrity (refer to Chapter 15 for this
one, too) so MariaDB does not allow the deletion of rows that have
data in other tables related to them.
Caution
Use with Caution The bottom line is that MariaDB has no Undo button. Be very careful
using UPDATE and DELETE , or you might find yourself updating and deleting the wrong
data.
Summary
In this chapter, you learned how to use the UPDATE and DELETE statements
to manipulate the data in your tables. You learned the syntax for each of these
statements, as well as the inherent dangers they expose. You also learned why
WHERE clauses are so
important in UPDATE and DELETE statements, and you
were given guidelines to follow to help ensure that data does not get damaged
inadvertently.
 
 
Search WWH ::




Custom Search