WEBVTT

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

00:10.880 --> 00:18.530
And in this video lecture we go ahead and look at what is known as autocommit commit and rollback.

00:18.530 --> 00:24.140
So this three key ways we have asked to be able to work with our database safely.

00:24.140 --> 00:29.210
So you can remember that when we try to delete our database I told you not to do that.

00:29.240 --> 00:32.960
So I said delete from a strings.

00:32.960 --> 00:34.910
So under action how to do this.

00:34.910 --> 00:36.530
Because if we do that it's dangerous.

00:36.560 --> 00:38.600
It's going to delete whatever that we have here.

00:38.690 --> 00:44.000
The reason is because I have not been able to save this.

00:44.030 --> 00:48.560
The reason is that I need to put this in a mode that will help me to recover whatever I do, and that

00:48.560 --> 00:51.380
is where Autocommit comes into play.

00:51.410 --> 00:57.740
Now, if I go ahead and, uh, set Autocommit equal to zero, it means that this will not be committed.

00:57.740 --> 01:02.680
It will not be, uh, once we execute the query, it's not going to be saved automatically.

01:02.710 --> 01:03.460
All right.

01:03.610 --> 01:05.890
Go ahead and say set.

01:06.220 --> 01:16.960
And then I'm going to say set a autocommit and let autocommit be equal to all.

01:16.990 --> 01:19.330
And then go ahead and press semicolon at the end.

01:19.360 --> 01:21.700
Now I'll go ahead and execute this query.

01:21.700 --> 01:26.230
And down here you can see that we have set autocommit equal to f.

01:26.290 --> 01:31.990
And we set autocommit because of a warhead and the commit that.

01:32.260 --> 01:32.710
All right.

01:32.710 --> 01:34.450
So go ahead and commit this.

01:34.450 --> 01:39.100
And if you go ahead and hit on commit you can see down here we have commit.

01:39.100 --> 01:42.970
And that is green showing that you have already committed this.

01:43.000 --> 01:46.240
Now anytime I use commit it means I want to save this.

01:46.270 --> 01:46.720
All right.

01:46.720 --> 01:49.300
So anytime I say commit it means I want to save it.

01:49.300 --> 01:51.340
And that is why I'm using commit.

01:51.550 --> 01:57.190
But if I don't use commit it will not be saved automatically because I have disable auto commit.

01:57.220 --> 01:57.610
All right.

01:57.610 --> 01:59.680
So we have to always manually save it.

01:59.700 --> 02:01.920
Now I can confidently go ahead.

02:02.130 --> 02:05.910
And first of all, maybe I say delete.

02:06.690 --> 02:11.520
So delete are from students.

02:11.520 --> 02:12.810
So they're from students.

02:12.810 --> 02:19.230
Then first of all we are class because I want us to be safe and do this step by step.

02:19.230 --> 02:21.570
We are students.

02:22.950 --> 02:31.650
So we are students are ID is equal to let me say eight and then we call end.

02:31.680 --> 02:37.500
And then we go ahead and show that as guidance say select.

02:37.920 --> 02:44.070
And then we can now say from students and put semicolon.

02:44.190 --> 02:47.610
And now this corps had and the is the key to this query.

02:47.610 --> 02:49.440
And then let's go ahead and check.

02:49.470 --> 02:54.900
So the students are just who have deleted this all right.

02:54.900 --> 02:56.190
And is no longer here.

02:56.190 --> 02:59.690
And now if we want to get that back again.

02:59.720 --> 03:02.930
I'll go over here and remove this arm is what's called rollback.

03:02.930 --> 03:06.020
So this is a keyword to say rollback.

03:06.020 --> 03:09.800
And then we call it end and execute this.

03:09.830 --> 03:13.790
Now you can see I have Steve right in here back again.

03:13.790 --> 03:17.690
So I can confidently now tell you to delete.

03:17.690 --> 03:20.030
And you go ahead and delete.

03:20.060 --> 03:32.570
But if I should go ahead and say delete and then I'll go ahead and say from students.

03:32.750 --> 03:40.010
And then we're then we're going to say we are the student ID.

03:42.050 --> 03:45.020
Is equal to eight, which is just Steve.

03:45.020 --> 03:46.760
And then put a semicolon at the end.

03:46.760 --> 03:49.880
And let's go ahead and execute this query again.

03:49.910 --> 03:52.610
Now Judge Steve is no longer there.

03:52.640 --> 03:56.660
Now I'll go ahead and say commit.

03:57.770 --> 03:58.100
All right.

03:58.130 --> 04:00.640
So our I always use a uppercase.

04:00.640 --> 04:04.240
So commit a semicolon at the end.

04:04.270 --> 04:05.740
Now go ahead and execute this.

04:05.890 --> 04:10.810
So now you can see we have a this already saved.

04:10.840 --> 04:17.140
If I should go ahead and roll back I'm not going to get anything called Judge Steve again because it

04:17.140 --> 04:18.700
is already committed.

04:18.700 --> 04:25.510
And now you can see that, uh, Judge Steve is entirely wiped off because I have already committed.

04:25.510 --> 04:29.830
So the auto commit has been set off by my analysis of this, by myself.

04:29.860 --> 04:39.730
Now, if I should go ahead and, uh, say delete and I'm going to say delete, uh, from students,

04:39.760 --> 04:44.050
and this is going to intend to wipe out everything we have here.

04:44.080 --> 04:46.000
Go ahead and run this.

04:46.000 --> 04:49.390
And you can see that our table is entirely empty.

04:49.630 --> 04:53.950
We can always use a rule back because we have not committed this automatically.

04:53.980 --> 04:56.530
So go ahead and say rule back.

04:57.870 --> 05:00.960
So grow back and then go ahead and execute this.

05:00.960 --> 05:05.610
And you can see how my table board church two is no longer there because I've already committed that

05:05.610 --> 05:06.150
already.

05:06.150 --> 05:12.780
So you can see that this isn't the commit we can go to manually actually commit our save this.

05:12.810 --> 05:13.110
Right.

05:13.140 --> 05:16.740
So in this video lecture we are able to discuss about auto commit.

05:16.770 --> 05:19.440
We know how to set up auto commit equal to off.

05:19.440 --> 05:20.850
And we can.

05:20.880 --> 05:30.480
We always go ahead and save it manually by using the commit keyword and this query to receive our project.

05:30.480 --> 05:38.550
So in that you can actually uh, delete and then go back to what you have previously and you can actually

05:38.550 --> 05:40.260
recover whatever you just did.

05:40.260 --> 05:41.310
So that is cool.

05:41.310 --> 05:42.600
So let's run with it.

05:42.600 --> 05:45.810
And if you have any question please go ahead and use the question and answer section.

05:45.810 --> 05:48.210
And I'm going to see in the next video lecture.

05:56.040 --> 05:56.520
Nine.
