In this third part to a series on beginning SQL, you'll learn how to use SQL statements to manipulate entire tables: to join them, alter them, and even delete them. It's all part of keeping a firm grip on your databases. Keep reading to learn more.
Now that we've wedded some tables in unholy matrimony and made some babies, let's add to our amazing powers and learn the CREATE statement.
With the CREATE statement you can create new tables and even an entirely new database. Before we do however, let's discuss data types.
In short, the data type defines what sort of data a column can hold. If you signify that a field is a date field, and try to enter text into that field, your database will yell at you. Everything has a place, and put the proper things there. And close the door. What, were you born in a barn?
The following table shows the different data types available.
For character strings with a fixed-length
For character strings with variable lengths
For integer numbers
For holding numbers with decimals
For numbers with floating points
For dates and times
For holding time intervals
There are other forms of data types, but they are beyond the scope of this article. For the time being, these should suffice.
So now your boss wants a new database. This one will show the employees' names and how long they have been with the company. We will call this database Seniority. To create the database in SQL, do the following:
CREATE DATABASE SENIORITY;
It's just that simple. Or is it? Of course it isn't. We also need a table for our database. So let's create that now.