From the course: Learning SQL Programming

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Removing data from a table

Removing data from a table - SQL Tutorial

From the course: Learning SQL Programming

Start my 1-month free trial

Removing data from a table

- [Instructor] Removing a row of data from a table can be accomplished with the DELETE keyword. As with an UPDATE statement, we need to tell the database from where it should delete something, and it's a good idea to add a condition to set the scope of deletion; otherwise, we'll delete everything in the table. For example, this is a completely valid DELETE statement and would remove all the records from the people table. That's not something we want to do right now though. So let's add some more context to the statement and target specific records to delete. First though, let's take a look at our table and find some unlucky records to delete. I'll remove some of these incomplete records that we've just added. Let's start with Bob. And before we delete, let's make sure to test our logic so we know that we're only getting the record that we intend to work with. Bob's ID number is 1001. So I'll write SELECT * FROM people WHERE id_number=1001. That looks like my WHERE condition matches…

Contents