1. Home
  2. Computing & Technology
  3. Databases

Creating Databases and Tables In SQL
Modifying Tables

By , About.com Guide

In the previous two sections of this article we explored the design of a database and the creation of tables to populate that database with information. In this final segment, we'll look at the mechanism SQL provides to alter the structure of a database after creation.

If you're particularly astute today, you might have noticed that we "accidentally" omitted one of the design requirements when implementing our database tables. XYZ Corporation's HR Director requested that the database track employee salary information and we neglected to provide for this in the database tables we created.

However, all is not lost. We can use the ALTER TABLE command to add this attribute to our existing database. We want to store the salary as an integer value. The syntax is quite similar to that of the CREATE TABLE command, here it is:
ALTER TABLE employees
ADD salary INTEGER NULL;
Notice that we specified that NULL values are permitted for this attribute. In most cases there is no option when adding a column to an existing table. This is due to the fact that the table already contains rows with no entry for this attribute. Therefore, the DBMS automatically inserts a NULL value to fill the void.

And that wraps up our look at the SQL database and table creation process. Check back often for new installments in our SQL tutorial series. If you'd like an e-mail reminder when new articles are added to the About Databases site, be sure to subscribe to our newsletter!
Explore Databases
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Databases
  4. Learning SQL
  5. Modifying Tables>

©2009 About.com, a part of The New York Times Company.

All rights reserved.