| Lesson 7 || Using DELETE |
| Objective || Delete a row from a table. |
Delete table Row using SQL Server
Over time, databases can become very large and result in deteriorating performance. You should plan on periodically taking the time to remove records that have become obsolete or have been inactive for an extended period. This type of spring cleaning will improve performance and reduce storage requirements because there are fewer rows to sort or search through. Reducing the size of the database also frees up disk space
that might be needed for something else, such as swap space
Caution should be exercised when deleting data. It's a good idea to archive the data before deleting it from a production database
statement to remove rows from a SQL database. The syntax
is similar to the
statement except that you do not specify column names since the entire row will be deleted. The following
statement will remove all
rows from the BookTable table:
DELETE FROM BookTable
Now you see just how easy it is to remove an entire table of data!
Now let us look at a more practical and less catastrophic example. The book, Maintaining Your Moped, has had poor sales and will no longer be carried by VirtualBookShelf.com.
The following Slide Show describes how the
DELETE statement is used to remove only this record from BookTable:
Using Delete Statement
The next lesson wraps up this module and lets you take a quiz to test your knowledge about basic SQL statements.
swap space or swap file:
Disk space used by the operating system to temporarily remove information from main memory.
Most of the actions you need to perform on a database are done with SQL statements.
A database in use in the production environment.