Removing a row in a sql table

Screen Link:

https://app.dataquest.io/m/257/guided-project%3A-analyzing-cia-factbook-data-using-sql/6/exploring-average-population-and-area

Hi! please how do I completely remove a row from a sql table.
in the mission, the world data is included in the table so for each computation I have to write WHERE name != “World” to get accurate values. but sometimes I forget.
is there a way to drop the row completely?

You can delete that row from the database, but then it will be gone. You won’t be able to access it again (at least not in a easy and natural way) from within the database.

I suggest an alternative instead, which is to create a view. You can think of a view as a saved query.

By running the code below, you’ll create a view which you can access just like querying the facts table.

CREATE VIEW facts_wo_world AS
SELECT *
  FROM facts
 WHERE name <> 'World';

To query the view instead of facts, you replace facts with facts_wo_world.

If you really want to drop the row from facts, you can run the following.

DELETE FROM facts
 WHERE name = 'World';
3 Likes