Update query in sql
- how to delete a row in sql
- how to delete a row in sql server management studio
- how to delete a row in sqlite
- how to delete a row in sql oracle
How to delete a row in sql oracle...
Problem
You want to remove a row / rows from a table.
Example 1
In the table, there are names of the students and the results of the exam.
name | result |
---|---|
Janet Morgen | 9 |
Taya Bain | 11 |
Anne Johnson | 11 |
Josh Kaur | 10 |
Ellen Thornton | 8 |
You want to remove the row for Ellen Thornton.
Solution 1
DELETE FROM exam WHERE name = 'Ellen Thornton';The table now looks like this:
name | result |
---|---|
Janet Morgen | 9 |
Taya Bain | 11 |
Anne Johnson | 11 |
Josh Kaur | 10 |
Discussion
Use with the name of the table from which you'd like to delete a row.
In , write the condition specifying the row.
Delete multiple rows in sql
If you have a specific row in mind, it is best to write the condition using the column containing unique values. Here, the unique column is .
If there are many rows whose name equals , all of them will be removed. If there is no such name, no rows are removed.
Example 2
In the table, there are names of the students and the results of the exam, just as in the previous example.
name | result |
---|---|
Janet Morgen | 9 |
Taya Bain | 11 |
Anne Johnson | 11 |
Josh Kaur | 10 |