I welcome you back again to the lecture on PostgreSQL.
And let's go ahead and learn how to drop the database.
All right.
So what is a database called students.
And we can actually drop that database.
But this is a very dangerous command in PostgreSQL or in any SQL development or in database.
Why is that a dangerous command is because something you've worked for over a long time can be deleted
within a twinkle of an eye.
So if we want to drop a database, you should always know that the database you want to drop is a database
you don't need.
So if it's a database that you need, you don't.
Kohat just drop that because you're going to lose every information there.
So imagine you have a database, uh, which contains millions of data, login details, passwords and
email addresses and so many more.
And you mistakenly drop that database.
You cannot get that again, except you have a bug of some way which you can actually retrieve and work
on.
So let me go ahead and show you how to drop a database.
Now go over here and let's go ahead and list all our database.
So whenever you write backward slash L it means backward slash list.
And if you click on that you're going to see every database you have.
Now if I want to drop a database all I need to do is go ahead and save drop.
And I'm going to see database.
Then I'm going to give the name of the database.
So overriding day.
And I'm going to select student.
And then put a semicolon at the end.
And go ahead and hit enter.
And your database will drop.
All right.
So that is coming off in a very soon it's going to drop he says error database student is being accessed
by other users.
That is one other session is in the database.
All right.
What I want is that I have my admin.
And all I need to do is I can actually go ahead and close the admin, and then I'll open it up again,
and then the database will be dropped because I'm running admin and I'm running the show as well.
So go ahead and, uh, close this.
Let's go ahead and close this.
And it says, do you want to quit the application?
Yes.
And now let's completely go ahead and drop this database again.
So go ahead and say drop that, uh, base and the student employee semicolon and go ahead and uh you
can see drop database.
So whenever you're using Pgadmin and uh SQL shell, these are two different applications.
You either use the graphical interface, the application that is the admin is a graphical interface
application where we can be able to actually do exactly the same thing we are doing right in here.
I'm going to show you one example on that.
So as time goes on, we're going to see an example of how to use the admin graphical user interface
to write queries.
All right.
Now I'm going to also maintain the use of uh SQL in this course because that is one of the defaults
that is most lovable that people use in writing PostgreSQL queries right now.
If you go ahead and open Pgadmin over here, you can see I have only one and I have only Postgres that
is here.
All right.
So the student database has been dropped and I can go back and create that database again.
Go ahead and uh c create database and uh just to the inspiration icon and, and and I'm going to click
on this and it creates a database.
So you can see that why I open up this I was able to create a database because I'm doing a simple action
that is acceptable.
But what I wanted to drop this database, it let me know that this database is open somewhere showing
that that command is very, very dangerous.
Now I can go over here and refresh this and I'm going to see students.
You see that.
And the students database has been created again.
So go ahead and uh create a third database and drop it.
So you can actually learn how to drop a database in PostgreSQL.
And that is very interesting.
So if you have any question under this course, had I use the question and answer section, and I'm
going to get back to you as soon as possible.
Thank you so much.
And I'm going to see you in the next video lecture.