Welcome back.
Let's go back into our database.
We've just created our users table. But now we want to actually insert some information. How can we do
that? Again using SQL we have the 'insert into' command that we're able to insert into whichever
table name we want.
We're going to specify the column and then the values of each of those respective columns and always
ending in a semicolon.
I also want to emphasize that with SQL the capitalization is just a standard.
But if I made this lowercase it will still work.
It's case insensitive.
So looking at our database we have name, age and birthday.
Let's insert something. We'll say that we want to insert into
users
column_1 will be name and then we have age,
birthday
and no you don't have to insert every time into every column. You can just change the name if you want.
Alright name will be
'Andrei'
value will be 31 and then BIRTHDAY we'll say is if you remember the day syntax if i open up here is
this year, month, date.
So I simply do 19-
I'm going to make myself really old. We'll say January 25th. Press enter I get insert, awesome. If I do
\d again.
I see my table but how can I see the value that I just entered.
Well first let's check here.
Let's check with our GUI. Click on content, select users and look at that name, age, birthday. I have Andrei
31 with my birthday.
Very cool.
Now, how can we grab this information?
Again a SQL syntax is 'select' and we want to say what we want to select.
In our case we can say name, age, birthday.
From and then the table name.
In our case users. Semi-colon, press enter and look at that
I get Andrei, age 31, birthday. If I want to just grab the entire columns without spelling out everything.
Imagine if we had tons of columns. We can use the wildcard symbol of star that's shift + 8 to get star
and I get the same thing.
Very cool.
By the way with PSequel, we can actually run these queries here.
See how it already has 'select'.
I can say select * from users and it even gives me nice coloring, press ENTER or press semicolon
and run query and look at that.
It gives me the table for me. And it also has the history which is really really nice.
Let's add a few more users here.
I'm going to insert this time somebody else.
I'm just going to change a few things.
41 And Sally inserted.
If I select star from users I have Andrei and Sally. Going back here,
run query. I have Andre and Sally in the database.
How cool is that.
All right we know how to create a table.
We know how to insert into a table and we know how to grab this information. We can already start picturing
what powers we can have now with our final project. But there's still a few more things we want to learn.
For that I'll see you in the next video bye-bye.