-: Hi guys and welcome back.
In this video we're going to show you how to delete
entire tables using the drop table command.
It's pretty straight forward,
all we have to do is say drop table
and then the table we want to drop.
The first part tells the database that we want to
delete the table as if it never existed
and the second one is just a table
that we want to delete.
And that's really it.
We can add an if exists clause in there
to prevent a database error
if the database doesn't already exist.
For example, if we were to execute the command twice
you need this in order to prevent that error
the second time.
Let's go into the SQLite viewer
and have a look at how we can code this ourselves.
All right we're here in DB Browser
and I just wanted to show you how you can
delete tables in here.
First of all, if you go to database structure
you can just select the table and click this
delete table button.
That's the easiest way.
You can right click and delete a table like that
or you can of course go into the execute sequel tab
and type drop table users.
Then running that will get rid of the table completely.
Now of course if you run this again,
you're gonna get an error because it doesn't exist
so, like similar to create table we can do if exists.
Remember with create table we used if not exists
because we want to create it and here we need to use
if exists because we're trying to delete it if it is there
and so running this now gives us no error
because it only runs the drop table
if it already exists.
All right, hope this has been useful.
Thank you for joining me.
I'll see you in the next video.