★ wanayoo — archive 1999 http://wdvl.com/Authoring/DB/Intro/create_table.htmlNouvelle recherche | Portail wanayoo

Free Web Developer Info! logo

internet.com
Join the free
WDVL newsletter!

home

Creating Tables

August 16, 1998

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.

Creating Databases
Introduction to Databases for the Web | Table of Contents
Deleting Databases and Dropping Tables and Views

Up to => Home / Authoring / DB / Intro

Instantly look up a "techie" word using Webopedia!!


internet.com
e-commerce
WebDeveloper Network



Copyright 1999 internet.com Corporation. Legal Notices. Privacy Policy.

www.internet.com