I will call you back again to another video lecture in MySQL.
And in this video lecture we go ahead and look at what is known as autocommit commit and rollback.
So this three key ways we have asked to be able to work with our database safely.
So you can remember that when we try to delete our database I told you not to do that.
So I said delete from a strings.
So under action how to do this.
Because if we do that it's dangerous.
It's going to delete whatever that we have here.
The reason is because I have not been able to save this.
The reason is that I need to put this in a mode that will help me to recover whatever I do, and that
is where Autocommit comes into play.
Now, if I go ahead and, uh, set Autocommit equal to zero, it means that this will not be committed.
It will not be, uh, once we execute the query, it's not going to be saved automatically.
All right.
Go ahead and say set.
And then I'm going to say set a autocommit and let autocommit be equal to all.
And then go ahead and press semicolon at the end.
Now I'll go ahead and execute this query.
And down here you can see that we have set autocommit equal to f.
And we set autocommit because of a warhead and the commit that.
All right.
So go ahead and commit this.
And if you go ahead and hit on commit you can see down here we have commit.
And that is green showing that you have already committed this.
Now anytime I use commit it means I want to save this.
All right.
So anytime I say commit it means I want to save it.
And that is why I'm using commit.
But if I don't use commit it will not be saved automatically because I have disable auto commit.
All right.
So we have to always manually save it.
Now I can confidently go ahead.
And first of all, maybe I say delete.
So delete are from students.
So they're from students.
Then first of all we are class because I want us to be safe and do this step by step.
We are students.
So we are students are ID is equal to let me say eight and then we call end.
And then we go ahead and show that as guidance say select.
And then we can now say from students and put semicolon.
And now this corps had and the is the key to this query.
And then let's go ahead and check.
So the students are just who have deleted this all right.
And is no longer here.
And now if we want to get that back again.
I'll go over here and remove this arm is what's called rollback.
So this is a keyword to say rollback.
And then we call it end and execute this.
Now you can see I have Steve right in here back again.
So I can confidently now tell you to delete.
And you go ahead and delete.
But if I should go ahead and say delete and then I'll go ahead and say from students.
And then we're then we're going to say we are the student ID.
Is equal to eight, which is just Steve.
And then put a semicolon at the end.
And let's go ahead and execute this query again.
Now Judge Steve is no longer there.
Now I'll go ahead and say commit.
All right.
So our I always use a uppercase.
So commit a semicolon at the end.
Now go ahead and execute this.
So now you can see we have a this already saved.
If I should go ahead and roll back I'm not going to get anything called Judge Steve again because it
is already committed.
And now you can see that, uh, Judge Steve is entirely wiped off because I have already committed.
So the auto commit has been set off by my analysis of this, by myself.
Now, if I should go ahead and, uh, say delete and I'm going to say delete, uh, from students,
and this is going to intend to wipe out everything we have here.
Go ahead and run this.
And you can see that our table is entirely empty.
We can always use a rule back because we have not committed this automatically.
So go ahead and say rule back.
So grow back and then go ahead and execute this.
And you can see how my table board church two is no longer there because I've already committed that
already.
So you can see that this isn't the commit we can go to manually actually commit our save this.
Right.
So in this video lecture we are able to discuss about auto commit.
We know how to set up auto commit equal to off.
And we can.
We always go ahead and save it manually by using the commit keyword and this query to receive our project.
So in that you can actually uh, delete and then go back to what you have previously and you can actually
recover whatever you just did.
So that is cool.
So let's run with it.
And if you have any question please go ahead and use the question and answer section.
And I'm going to see in the next video lecture.
Nine.