WEBVTT

00:07.610 --> 00:11.570
I will call you back again to another video lecture in MySQL.

00:11.570 --> 00:16.640
And in this video lecture, I'll go ahead and teach you how to create your own database.

00:16.760 --> 00:17.240
All right.

00:17.270 --> 00:22.760
Now in the previous lecture we are able to set up our MySQL workbench and we have not done anything.

00:22.760 --> 00:27.590
So going over here and go over to schemas move over here and click on schemas.

00:27.590 --> 00:33.380
And down here or up here you can actually see our system database.

00:33.410 --> 00:38.660
If you open up this you can see tables views stored procedures and functions.

00:38.780 --> 00:41.540
Yes you can actually use this system database.

00:41.570 --> 00:42.740
But we're not going to use that.

00:42.770 --> 00:45.380
We're going to create our own database from scratch.

00:45.380 --> 00:50.330
So in order to create our own database and database we create will actually appear in here.

00:50.360 --> 00:54.620
So go ahead and say create.

00:55.190 --> 01:01.550
Now if how to create you can actually use the lowercase because MySQL is not case sensitive.

01:01.580 --> 01:04.460
So you can actually go ahead and see.

01:04.490 --> 01:05.390
Great.

01:05.420 --> 01:08.930
And I can actually also go in and say create.

01:08.960 --> 01:14.600
You can see that each of them gives me a blue background showing that it is correct.

01:14.630 --> 01:15.260
All right.

01:15.260 --> 01:18.080
So I want to maintain the upper case.

01:18.080 --> 01:20.450
And that is what I want to use throughout this course.

01:20.480 --> 01:24.920
So I'm going to say create a data base.

01:24.920 --> 01:27.050
And then I'm going to give the name of the database.

01:27.050 --> 01:33.650
So for starting of this I'm going to say my DB though I'm going to change this later.

01:33.650 --> 01:38.660
But for now I want us to move ahead and create this workforce database.

01:38.660 --> 01:42.770
And then we can also create another database in this lecture.

01:42.800 --> 01:45.410
Now let's go ahead and move over to this point.

01:45.410 --> 01:49.580
We can see execute selected partial of the scripts or everything.

01:49.640 --> 01:51.590
Go ahead and hit on these.

01:51.620 --> 01:56.450
And down here you can see we have create database successful.

01:56.450 --> 01:59.510
You can see the green tick right here.

01:59.690 --> 02:06.730
And uh over here under the schema we can see the default database, which is a system database right

02:06.730 --> 02:07.090
in here.

02:07.120 --> 02:08.290
Now go up here.

02:08.290 --> 02:10.240
And what you're seeing is system database.

02:10.270 --> 02:12.280
You cannot see the database you created.

02:12.310 --> 02:15.010
The reason is because you have not refreshed your database.

02:15.010 --> 02:20.590
So anytime you create a database you go over here and click on this to refresh it.

02:20.830 --> 02:27.760
Right now I have my DB and I can see tables, views, stored procedures, functions, everything just

02:27.760 --> 02:29.980
like the system database.

02:30.310 --> 02:32.470
So now I hope that is cool.

02:32.740 --> 02:39.550
And you can see my schema still says that I'm using system database, which is not really what I want.

02:39.580 --> 02:43.120
I want to make my own database as a default database.

02:43.150 --> 02:44.740
How can I be able to do that?

02:44.740 --> 02:50.620
For me to do that I'll go right here, click on this and I can set this as default.

02:50.650 --> 02:54.220
But right now it's still not the default database.

02:54.250 --> 02:59.020
The reason is because when you click on this you can see no object selected.

02:59.020 --> 03:02.800
And the database I selected, which is my schema, my DB.

03:02.830 --> 03:05.290
It is not actually in use.

03:05.320 --> 03:09.250
The reason is because I have not set this database to be in use at the moment.

03:09.250 --> 03:13.690
So if I want this database to be in use, I'll go ahead and click this.

03:13.690 --> 03:19.360
And I'm going to say use my DB semicolon at the end.

03:19.390 --> 03:22.810
Then I'll go over here and execute this as usual.

03:22.840 --> 03:24.340
Now go ahead and click on this.

03:24.340 --> 03:33.340
And now you can see that my DB has a bold black color change that I'm actually using my DB right now.

03:33.340 --> 03:39.190
And down here you can see use my DB in green tick change that.

03:39.190 --> 03:41.530
This query was executed successfully.

03:41.530 --> 03:45.940
And now my db is what I'm using as a default schema.

03:46.270 --> 03:46.870
All right.

03:46.900 --> 03:47.650
Oh that is cool.

03:47.680 --> 03:52.540
Now let's go ahead and show you how to drop this database in case you don't want to use this database.

03:52.570 --> 03:55.450
The best way to do that is to go ahead and remove this.

03:55.450 --> 04:02.440
And I'm going to say drop database and then give the name of the database you want to drop.

04:02.470 --> 04:07.960
And go ahead and say my DB and never semicolon at the end of this.

04:07.960 --> 04:11.620
Now let's go ahead and execute this query now.

04:11.650 --> 04:12.730
Go ahead and hit on this.

04:12.730 --> 04:18.370
And you can see drop database and another schema no object selected.

04:18.370 --> 04:22.690
And over here under schemas I have only the system database right in here.

04:22.720 --> 04:24.190
So I hope that is cool.

04:24.190 --> 04:25.270
Wow that is good.

04:25.300 --> 04:32.020
Now I have dropped my DB and you have learned how to create, how to use and how to drop your DB.

04:32.050 --> 04:33.280
I hope that is fantastic.

04:33.280 --> 04:38.020
Now let's go ahead and create our own database which we are going to use in this course.

04:38.020 --> 04:44.860
So I'll go ahead and create a new database and we'll go ahead and say create database.

04:44.860 --> 04:49.810
And I'm going to give the name of my database to be my school.

04:49.840 --> 04:55.900
And at the end, because that is the database I want us to use for the purpose of this course.

04:55.930 --> 04:59.110
Go ahead and hit on execute this query.

04:59.110 --> 05:03.490
And I have create database MySQL already there.

05:03.520 --> 05:06.220
Now I go ahead and I use my school.

05:06.250 --> 05:08.170
I'll go ahead and say go ahead.

05:08.170 --> 05:08.980
And uh.

05:09.900 --> 05:14.160
use my school and go ahead and execute this query.

05:14.160 --> 05:22.110
And I have my SQL right here and over here I'm gonna have a fresh TS, I have my SQL corrected and I

05:22.110 --> 05:24.600
have my school also selected.

05:24.600 --> 05:27.990
And that is the schema we are using right now.

05:27.990 --> 05:29.220
So that is cool.

05:29.250 --> 05:32.730
And uh, what if I want to alter my database.

05:32.730 --> 05:36.780
You know, I created this database and drop this database as well.

05:36.780 --> 05:39.630
So when I created the database I dropped it.

05:39.660 --> 05:46.860
What I want to love this database to be grid only, and that you cannot be able to modify or drop the

05:46.860 --> 05:47.520
database.

05:47.520 --> 05:48.990
So how can I be able to do that.

05:48.990 --> 05:50.310
So don't drop my database.

05:50.340 --> 05:52.230
Now I'll go over here and delete this.

05:52.230 --> 05:53.790
And I'm going to write a query.

05:53.790 --> 05:58.620
And I'm going to say this to be alter database.

05:58.800 --> 05:59.250
All right.

05:59.250 --> 06:02.100
So order automata based MySQL.

06:02.100 --> 06:05.760
And then you go ahead and set this to be read only.

06:05.760 --> 06:11.010
So read only and let let this be equal to one.

06:11.040 --> 06:12.900
I put a semicolon at the end.

06:12.930 --> 06:21.180
So if I go ahead and execute this down here you can see our database MySQL read only equal to one.

06:21.180 --> 06:23.130
And that is successful.

06:23.160 --> 06:27.150
Now let's go ahead and drop this database and know if that will actually drop.

06:27.180 --> 06:28.530
Go ahead and remove this.

06:28.530 --> 06:33.030
And I'm going to say drop database.

06:33.030 --> 06:37.920
And the name of my database is my school.

06:37.920 --> 06:39.720
And then put semicolon at the end.

06:39.720 --> 06:41.760
And let's go ahead and hit on this.

06:41.790 --> 06:50.370
And you can see drop database MySQL error schema MySQL is in read only mode.

06:50.820 --> 06:51.450
All right.

06:51.450 --> 06:57.330
So at this moment you can be able to alter my database because I've set my database to be read only.

06:57.330 --> 07:00.930
And therefore you cannot be able to alter these.

07:00.960 --> 07:02.070
So that is cool.

07:02.100 --> 07:07.890
Now if I want to be able to open it again so I can alter my database, I'll go back and I'm going to

07:07.920 --> 07:18.860
say alter Data base, and I'll go ahead and give the name of the database to be MySQL, and I'll change

07:18.860 --> 07:25.310
that to be read only and let it be equal to zero and a semicolon at the end.

07:25.310 --> 07:27.620
And then go ahead and execute this.

07:27.620 --> 07:30.590
And I have other database.

07:30.620 --> 07:33.140
MySQL read only equal to zero.

07:33.140 --> 07:35.390
And that is what I have right now.

07:35.390 --> 07:39.620
So now you can go ahead and drop your database if you wish.

07:39.650 --> 07:45.380
But for the sake of this course and we're going to maintain these because we've learned how to drop

07:45.410 --> 07:45.980
our database.

07:45.980 --> 07:47.510
So we're not going to drop this at all.

07:47.510 --> 07:49.700
So go ahead and practice with these.

07:49.730 --> 07:54.350
If you go ahead and uh, try as much as possible to play around with it.

07:54.350 --> 07:58.220
And if you have any questions, go uh, use the question and answer section.

07:58.220 --> 08:00.740
And I'm going to get back to you as soon as possible.

08:00.740 --> 08:01.610
Thank you so much.

08:01.610 --> 08:04.670
And I'm going to see you in the next video lecture.
