How to Modify a SQL Database Table

Often newly created SQL database tables need some tweaking. If you’re working for someone else, your client may come to you after you create the database and tell you that she wants to keep track of another data item — perhaps several more. That means you have to go back to the drawing board.

If you’re building a database for your own use, deficiencies in its structure inevitably become apparent after you create the structure (it’s probably a clause in Murphy’s Law). For example, say you start getting proposals from other countries and need to add a Country column. Or you have an older database that didn’t include e-mail addresses — time to bring it up to date.

If a time comes when you need to update your database tables, take a moment to assess all the fields they’re using. For example, you may as well add a second Address field for people with complex addresses and a Country field for proposals from other countries.

Although it is fairly easy to update database tables, you should avoid doing so whenever possible. Any applications that depend on the old database structure are likely to break and will have to be fixed. If you have a lot of applications, this task could be a major undertaking. Try to anticipate expansions that might be needed in the future and make provisions for them.

Carrying along a little extra overhead in the database is usually preferable to updating a slew of applications written several years ago. The knowledge of how they work is probably long gone, and they may be essentially unfixable.

To insert new rows and accommodate changes, open the table and follow these steps:

  1. In the table-creation window, right-click in the small colored square to the left of the City field to select that row and choose Insert Rows from the menu that pops up.

    A blank row appears above the cursor position and pushes down all the existing rows.

    image0.jpg
  2. Enter the fields you want to add to your table.

    An Address2 field has been added above the City field and a Country field has been added above the Phone field.

  3. After you finish your modifications, save the table before closing it.

    image1.jpg
  • Add a Comment
  • Print
  • Share
blog comments powered by Disqus
Advertisement

Inside Dummies.com

Dummies.com Sweepstakes

Win $500. Easy.