17 Updating and deleting data

 

Chapter 16 discussed inserting new rows of data into tables and contained our first exercises for doing something with SQL other than reading data. The chapter also briefly mentioned that the INSERT keyword is one of several used for data manipulation.

This chapter examines two other ways of manipulating data: updating and deleting. Because SQL is designed to be intuitive for English speakers, we’ll work with the keywords UPDATE and DELETE, respectively.

17.1 Updating values

Updating data is a bit different from inserting data, in that we’re manipulating data at the column level instead of the row level. Recall that tables have rows, and rows have properties represented by columns. When we update data in SQL, we’re updating the values of those properties, so we’re making changes at the column level.

These changes may or may not include all columns in a given row, and they may or may not involve updating the values of one or more columns of every row in the table. The point is that we have many options for updating data in SQL. If this discussion is confusing, some examples may help you understand the options.

17.1.1 Working with data manipulation in real time

17.1.2 Requirements for updates

17.1.3 Updating values in one or more columns

17.1.4 Updating values with a multitable query

17.2 Deleting rows

17.2.1 Deleting one or more rows

17.2.2 Deleting a row with a multitable query

17.2.3 Deleting all rows in a table

17.3 One big tip for data manipulation

17.4 Lab

17.5 Lab answers