Let's go out here and learn how to insert data into a table in PostgreSQL.
So to insert the type of table, we need to use a keyword.
And that keyword we're going to use is called insight.
And the insight into the table and the table name is a student.
So students and then because we have the primary key already autoincrementing at ease the stress id,
I want to insert this on the the first, the first name.
So first name last name then the GP.
And one thing is that a GP has a precision of one by one means that is not going to be more than one.
So we're going to insert only 0.9 or 1.0 or 0.8, 0.7 or 0.5.
So if you want to increase that to like 4.7, 2.5 for Namazga-tepe, you're going to increase the precision
and the scale to maybe like a 3 or 4 by anything.
So you can start maybe precision of a five by 5 or 2 by five or so on.
But if you use precision of one by one, just like we did when we created this table, we're going to
be limited to only 0.9, 0.8, 0.7 and so on, or 1.0.
Okay.
So the next one is that we're going to enter the a row underscore date.
And then the email we're going to set the email.
Now we need to add values because I've not entered the semicolon.
So I'm still working on that.
This okay until I enter the semicolon.
That is when this query was executed.
So Values and what values they were.
First name there is going to be Peter, so that is for the first name.
Peter entered into the first name, and then the last name is going to be Jude.
And close the quotation mark and we go ahead and enter the GP.
So the GP is not going to be more than one.
So 0.9 if you enter anything like 4.7 you're going to get an error accepting.
Please, you cannot increase your precision to like a four by 3 or 4 by an anything or one by anything
and so on.
But for now we get one by one.
You're going to be limited to only 0.9, 0.8, 0.7, 0.5, 1.0.
And you can go on and that.
Now that is not really good for GP because no GP can be 0.1.
That is, you're really way too small.
So the in red dates we're going to see dates and the text is going to start by the year.
And let me say it is a 2019, 2019, and the month is a February zero two and the day is zero six.
And go ahead and, uh, enter the email.
So let me say the email is going to be Peter.
And uh, let me say Peter Jude at uh gmail.com.
But see if this is going to be inside a single quote.
And I'm going to say Peter, Jude at gmail.com and the quotation mark, and then go ahead and close
this.
And I'm going to put a semicolon at the end.
And now that I've entered the semicolon, it means that I can now go ahead and execute this query.
So go ahead and hit enter.
And you can see we have insights zero one.
And then let's go over here and check it out.
So select all from students.
And if I execute this query let's go ahead and you can see stress ID.
The first one here is the ID the stress ID and the primary key one the first name Peter.
The last name Jude GP is 0.9.
And the erode date is uh these 29 00206 and email is this.
Now I can go ahead and insert a SQL one if I go ahead and copy everything right in here.
Let's go ahead and copy everything here.
And now you can see that I copied that twice.
And anyway it says terminates bad job.
It can go ahead and say yes or no.
But because I've copied that twice and I'll go over to show and continue from here.
So let's go ahead and show you how to do that from this place.
So I'll go ahead and paste what I just copied.
And that is insights from students.
Go ahead and increase this.
And uh, I'll go ahead and add the values.
So go ahead and add values.
So the values now want to add is uh open and close with a semicolon at the end.
And there are a warhead.
And the first one of the themes I just have then a warhead and it did that.
So I have the first name to be Barak.
Then ask them to be Harry.
And uh, like I told you, the GMO is not going to be more than the zero points, is open to more than
one.
All right, then, go ahead and say that, uh, it's going to be like a 0.8.
And then this is the date.
And for the dates we go ahead as a date.
And this is going to be single quotation Mark is going to use single quotation mark.
All right.
So.
I'm going to do this without an email because the email is nullable.
All right.
And if I actually run this code I'm going to get this inserted right in here.
So if I go ahead and run this let's go ahead and check it out.
It says insert has more target colon than expression.
And uh insert into these.
We have the GP, we have enrolled date and we have the email is pointing to the email that we need to
insert the email now because I don't want to insert into the email, I'll go ahead and remove this email.
And now I'll go ahead and uh click on this.
And I have the email.
Now what if I don't want if I want to insert this and uh, let me go ahead and remove the last name.
Let's go ahead and remove the last name.
So the last name is removed and, uh, I'm going to change the first name.
And let me say the first name is going to be Sarah.
And then let me see, the last name is going to be equal to Rocky.
And let me go to um, 0.7.
And we change the enrolled date to 2090.
And uh, let this be ten and let this be five.
And now let's go ahead and insert this and execute this query.
And you can see insert has more expiration than target.
And uh look what happened actually is that I have Rocky and I need to remove that so that's we can actually
deal with that's the last name.
Then we'll go ahead and execute this.
And it says third row contains three DS value encoding.
Last name of Russian students violates not no constraint.
So you see that not no constraints.
So no value in column.
Last name of Russian students violates not null constraint.
But what we entered the email we are able to actually enter the email.
And nothing actually happens because the email is nullable.
But we are not expected to enter any data with the last name.
So the last name must always be there.
I just wanted to enter the first name, the GP and erode date.
And uh, I didn't add the last name, but it's not possible.
But you can do that without the email.
All right.
So this is the difference and why the constraint is always there.
You can no longer insert any data without first name, last name, GP or erode date, but you can insert
the data with a out, an email and it will go on and work out fine.
Now if I go ahead and add last name, let me go ahead and add last underscore name.
You can see that Sarah is not added.
All right.
So what actually happens while the uh form it increments from one to 2 to 4.
And instead of three is because this primary key actually incremented when it's wanted to add this.
And it can't go back to three anymore.
Right.
So it's moved over to four because Sarah is omitted the last name.
So it has already created the key and found out that it's missed.
There are no constraints or it violates less a no constraint and that is why it didn't add it.
Now it has a primary key of, uh, one, two and four and instead of three.
So now you can see that you cannot be able to add anything without adding what a first last GP and enroll
date.
So that is the function of the no constraint making sure that we add everything complete.
All right.
So without adding everything complete it means that we cannot insert that data into our table except
the email.
Because email is nullable.
So go ahead and practice with this and check it out.
And if you have any question or how do 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.