#8 Introduction to PostgreSQL: Creating New Table Rows


English (Auto-generated)

in this video we're going to learn how to answer values into our tables. So I have already logged into my user name and we have already connected to our database. So let's type black slash D. T. To check out what tables we have. So we do still have the pets table in our previous example but we have not inserted any values into it. So it's sort of our using two table is fairly easy. All we have to do is type insert into. So usually the table name here and our table name is pets. So well right pets. And again you can write this in separate column. Let me separate rose. Or you can write it all in one line. So if you guys still remember in our pets table we have an I. D. Name and a. So the first bracket the parameters that we have to include is a column in our table. But because our I. D. Was a serial primary key meaning that they were going to increment our I. D. For us automatically. We do not have to write I. V. Rather I. D. Was not a serial primary key. You should include it because you would have to manually insert data into it or else your table would come up as no or empty. But for this example since it was it is a serial primary key we can go ahead and delete it. So we want to insert into table name and the table columns. So this is the first part of it. And as I mentioned before without the semi columns, this sentence will not execute. So feel free to type enter and I write in value. So right now we want to input the values for the name and age. So for name I guess um we can call the Pet oreo for age, oreo is five years old. Remember when you take the semi colon? This whole this to sentence will execute. So oreo does not exist. Oh whoops I forgot that. Um And SQL is very specific to postgres. We can only write it in single quotes and not double quotes. And if you write it in double quotes it will tell you that there's a column error because oreo does not exist. So as you can see after we change it to single quotes we have successfully inserted into our pets table. So to check that this query or in certain work we can pick. So like star Star just means select everything from this table. So from pets, remember the semicolon or it won't execute and you will see that we have successfully entered our first values into the table. And as I mentioned before because it's a serial primary king. If we add in another set of values it will auto increment into two and then three and four by itself. So you don't have to keep typing the I. D. Values or I. D. Column into each insert. And as you can see for our name we were able to write oreo and ages five
94 Views 1 Likes 0 Comments

This video will teach you how to insert new values into tables.

Leave a comment (supports markdown format)