IBM Books

SQL Getting Started


Deleting Data

Use the DELETE statement to delete rows of data from a table based on the search condition specified in the WHERE clause. The following example deletes the row in which the employee ID is 120:

 
     DELETE FROM PERS
        WHERE ID = 120

The WHERE clause is optional and it specifies the rows to be deleted. If the WHERE clause is omitted, the database manager deletes all rows in the table or view.

You can use the DELETE statement to delete more than one row. The following example deletes all rows in which the employee DEPT is 20:

     DELETE FROM PERS
        WHERE DEPT = 20

When you delete a row, you remove the entire row, not specific column values from it.

To delete the definition of a table as well as its contents, issue the DROP TABLE statement as described in the SQL Reference.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]

[ DB2 List of Books | Search the DB2 Books ]