O'Reilly logo

Head First SQL by Lynn Beighley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 3. DELETE and UPDATE: A change will do you good

image with no caption

Keep changing your mind? Now it’s OK! With the commands you’re about to learn—DELETE and UPDATE—you’re no longer stuck with a decision you made six months ago, when you first inserted that data about mullets coming back into style soon. With UPDATE, you can change data, and DELETE lets you get rid of data that you don’t need anymore. But we’re not just giving you the tools; in this chapter, you’ll learn how to be selective with your new powers and avoid dumping data that you really do need.

Clowns are scary

Suppose we want to keep track of the clowns in Dataville. We could create a clown_info table to track them. And we could use a last_seen column to keep track of the clowns’ whereabouts.

image with no caption

Clown tracking

Here’s our table. We can leave out information we don’t know and fill it in later. Every time we have a new clown sighting, we can add a new row. We’ll have to change this table frequently to keep it up to date.

image with no caption

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required