Once you have created your database you can then
start populating it with tables. In the case of Access, as you saw on
the last page, creating tables is as easy as clicking "New" in the table
tab of the "Database" tab.
However, you should know that in the background,
Access, and other GUI database systems are using the CREATE TABLE
command to create a new table.
This command looks like the following:
CREATE TABLE TABLE_NAME (COLUMN_NAME DATA_TYPE,
COLUMN_NAME DATA_TYPE,
COLUMN_NAME DATA_TYPE)
IN DATABASE DATABASE_NAME
For example, you might see the
following SQL code to create a table called PRODUCTS with three
columns in the MY_COMPANY database we just created. Note that the
three columns would be P_NUM which would be an integer value and could
not be null, the P_QUANTITY which would also accept integers as values,
and the P_PRICE column which would accept decimal numbers
with 8 digits before and 2 digits after the decimal point.
CREATE TABLE PRODUCTS (P_NUM INT NOT NULL,
P_QUANTITY INT,
P_PRICE DECIMAL(8,2))
IN DATABASE MY_COMPANY;
Notice that as we mentioned before, when you
create a table, you must specify the data type for each column.
Notice also that you may use the "NOT NULL" keyword to tell the
database that it should not allow any NULL values to be added to
the column.
As a final note, I would like to mention
that you can also typically create Views, Indexes, and Synonyms,
however, those topics are beyond the scope of this tutorial since
you will most likely not be doing database administration types of
activities. For most web development work, it is simply enough to define
some tables.