Okay, so in the previous lecture we dropped a primary key.
And now we want to add a primary key back.
Because if you go under student ID the bit ends.
There is nothing like a P key which is the primary key.
We have dropped it.
Now if I should go ahead and add this primary key, I'm going to get an error.
If I should go straight and do that from back, then go ahead and show you how to add a permanent key.
And we want to see other table.
And I want to alter either the students table.
So alter table students.
Then go ahead and add the primary key.
All right.
Now I'm going to add that to students underscore ID you can actually add this primary key to any of
these columns so we can add to multiple columns for Y.
I just want these to be here is because I just want that to just be for the stress ID.
You can add that to maybe email or you add that to first name, last name, or because people are going
to have exactly the same first name or last name.
Yes, some two or more pieces can have exactly the same first name and last name.
It happens, but they can't have the same email address.
Yes.
So it can also add email address to also be a primary key.
But there's a problem right in here.
If I should go ahead and uh, actually put a semicolon at the end of this and try to create this primary
key, I'm going to run into a problem.
Let me go ahead.
I show you that it says the stress ID is duplicate could not create a unique index stress ID because
Perimeter.
We have the two people still there and that is don't go ahead and check them out.
If we go ahead and check out these, we still have these two guys here.
So first of all we need to delete these two people from here so we can be able to add our primary key.
And to do that we go ahead and use the delete key word from the students table.
So delete from students.
Uh we have the ID or we are the students.
Underscore ID is equal to one.
And put a semicolon at the end of it and underscore here and is equal to square.
And check it out.
So we deleted two of them and they are gone right now.
I can also go ahead and then put back our primary key a warhead and the other the table.
So alter table and the table is a day student so terrible.
Students are ahead and are at the.
Primary key.
So at primary key.
And now we're going to add that primary key to.
The students underscore ID the input is semicolon at the end of it.
Now we can go ahead and execute this query and check it out.
So our table.
Now if I should go ahead and uh select all from students and put a semicolon at the end.
Let's go ahead and check it out.
So you can see that the primary key is back.
And we have deleted one of these, uh, students.
And our table is now 999 out of 999.
Let's go ahead and, uh, add back the student.
Let's go ahead and put in this back again.
So this is what we copied from the coach studio.
Uh, studio code, which will have right in here.
So I'm going to put this back again.
But, uh, right now we go ahead and, uh, set this, go ahead and, uh, execute this query.
Let's check it out.
So I've inserted it and then I can go ahead and uh select all.
Select all from.
So go ahead and select all from students and put a semicolon at the end.
And let's go ahead and run this and check it out.
So now we have added this as a last one.
And uh over here you can see we now have 1000 rows.
And uh the stress ID is not One for Marco and Love, and we just have one of each right in here.
So it is no longer duplicates because the primary key is back.
That is it.
So we have seen that we can be able to remove, and it can also add the primary key back to any of that
column.
Now the students or the first name, the last name, the email, the gender, the row, date or column.
So you choose one of these and add your primary key to it.
So your primary key, your primary key is going to always be your neck.
So you add that to either one of them, either the student's ID, the first name, last name, or the
email address, or the gender, or the date or the country.
So you choose one of them and add your primary key to that.
So that is it for now.
And if you have any questions, 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.