So the code begins with the two SQL keywords create and table that together the name of teachers, the
signal PostgreSQL that the next bit of code describes the table to add to the database following an
opening parentheses.
The statement includes a comma separated list of column names along with their data types for style
purposes.
Each new line of code is on its own line and in indented four spaces so isn't required but makes the
code more readable.
So each column.
So you can also write this like that.
And here like that.
So it but it making writing the codes like that in SQL makes it more readable.
So each column name represents one discrete data element defined by a data type.
So the ID column here.
ID column here.
Uh, two is of the data type of big cereal, right?
So here a spatial integer type that auto increments every time you add a new row title.
So in first of its the big big ID is going to one in second row is going to be three or in second,
one is going to be two, three, four, five, six and so on.
So.
Uh, we also have the force.
As I said, the first row receives the value of one in the ID column and the second row two and so on.
So the big serial data type and other serial types are PostgreSQL specific implementations, but most
database systems have similar feature.
So next we create columns for teachers first name and last name, and for the school where they are.
Teach each year of the data type var car a text column with a maximum length specified by the number
in parentheses, in this case 25, 50 and 50.
Uh, so.
Now, although this is a safe assumption, you will discover over time that exceptions will always surprise
you.
So the teacher's hire date here.
As you can see, our date here, teacher's hire date is set to the data type date.
And the salary column said to the data type of numeric.
So I will cover these data types more truly in next lectures, but this table shows some common examples
for the data types.
So the code block wraps up six with a closing parenthesis here.
Here This is the last the eighth line of code with the close parenthesis and a semicolon.
So now that you have a sense of how SQL works.
Let's run this code in Pgadmin.
So here I will also need to delete.
Oops, sorry.
Yeah.
Like this.
That's it.
Here.
Yes.
Now you have your code and you're connected to the database so you can make the table using the some
steps.
Same steps we did when we created this database.
So open the Pgadmin query tool, as I said, and just click on execute here.
Syntax error hiredate.
We have some errors with higher data and as you can see, we don't have comma here.
We will need that.
And here now let's run it again.
And that's it.
Query turned successfully in, uh, and milliseconds.
Write this here and we will refresh the data here.
And as you can see here we have here.
Foreign data wrappers.
Oxalic has.
We have here.
And we will have themes.
And as you can see here, we have five EFTs aggregative collections and domains and under that.
There is something called tables.
And as you can see here, we add our tables here.
Let's actually view this.
So you can also expand the teachers table node by clicking the arrow to the left like this of its name.
And this reveals more details about the table, including the column names here.
Other information appears as well, such as indexes, triggers and constraints.
So but I will cover those in later lectures and clicking on the table name and selecting the SQL menu
here.
Concrete.
As you can see, there is so much options here.
So click on the table and selecting the SQL menu in Pgadmin workspace will display a SQL statements
that will be used to recreate the teachers table.
And here the congratulations so far.
You built the database and added a table to it.
And the next step is to add data to the table so you can write your first query.